From 021fe010b6cbf5119938efbad3122ef2854fc62b Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Mon, 3 Oct 2016 18:30:40 +0200 Subject: [PATCH] API: Remove GtkPlug, GtkSocket and GtkWin32EmbedWidget --- docs/reference/gtk/Makefile.am | 5 - docs/reference/gtk/gtk-docs.sgml | 6 - docs/reference/gtk/gtk4-sections.txt | 43 - docs/reference/gtk/gtk4.types.in | 3 - docs/reference/gtk/x11.sgml | 7 - gtk/Makefile.am | 35 +- gtk/a11y/gtkaccessibility.c | 12 - gtk/a11y/gtktoplevelaccessible.c | 7 - gtk/gtkdnd.c | 14 +- gtk/gtkplug.c | 1401 ---------------------- gtk/gtkplug.h | 103 -- gtk/gtksocket.c | 1621 -------------------------- gtk/gtksocket.h | 89 -- gtk/gtksocketprivate.h | 61 - gtk/gtktestutils.c | 2 +- gtk/gtkwidget.c | 19 +- gtk/gtkwin32embed.c | 131 --- gtk/gtkwin32embed.h | 93 -- gtk/gtkwin32embedwidget.c | 385 ------ gtk/gtkwin32embedwidget.h | 75 -- gtk/gtkwindow.c | 24 +- gtk/gtkx-autocleanups.h | 31 - gtk/gtkx.h | 36 - gtk/gtkxembed.c | 242 ---- gtk/gtkxembed.h | 47 - gtk/makefile.msc.in | 2 - po-properties/POTFILES.in | 2 - po/POTFILES.in | 2 - tests/Makefile.am | 15 - tests/testsocket.c | 404 ------- tests/testsocket_child.c | 65 -- tests/testsocket_common.c | 286 ----- testsuite/gtk/notify.c | 11 - 33 files changed, 12 insertions(+), 5267 deletions(-) delete mode 100644 gtk/gtkplug.c delete mode 100644 gtk/gtkplug.h delete mode 100644 gtk/gtksocket.c delete mode 100644 gtk/gtksocket.h delete mode 100644 gtk/gtksocketprivate.h delete mode 100644 gtk/gtkwin32embed.c delete mode 100644 gtk/gtkwin32embed.h delete mode 100644 gtk/gtkwin32embedwidget.c delete mode 100644 gtk/gtkwin32embedwidget.h delete mode 100644 gtk/gtkx-autocleanups.h delete mode 100644 gtk/gtkx.h delete mode 100644 gtk/gtkxembed.c delete mode 100644 gtk/gtkxembed.h delete mode 100644 tests/testsocket.c delete mode 100644 tests/testsocket_child.c delete mode 100644 tests/testsocket_common.c diff --git a/docs/reference/gtk/Makefile.am b/docs/reference/gtk/Makefile.am index f62542c4a3..27afb34b16 100644 --- a/docs/reference/gtk/Makefile.am +++ b/docs/reference/gtk/Makefile.am @@ -157,7 +157,6 @@ IGNORE_HFILES = \ gtksidebarrowprivate.h \ gtksizegroup-private.h \ gtksizerequestcacheprivate.h \ - gtksocketprivate.h \ gtkstyleanimationprivate.h \ gtkstylecascadeprivate.h \ gtkstylecontextprivate.h \ @@ -233,7 +232,6 @@ IGNORE_HFILES = \ gtksearchenginesimple.h \ gtksearchenginequartz.h \ gtksequence.h \ - gtksocketprivate.h \ gtktextbtree.h \ gtktextbufferserialize.h \ gtktextdisplay.h \ @@ -248,9 +246,6 @@ IGNORE_HFILES = \ gtktreedatalist.h \ gtktreemenu.h \ gtktypebuiltins.h \ - gtkxembed.h \ - gtkwin32embed.h \ - gtkwin32embedwidget.h \ gtkwindow-decorate.h \ xdgmime \ xembed.h diff --git a/docs/reference/gtk/gtk-docs.sgml b/docs/reference/gtk/gtk-docs.sgml index 6e934877ea..6f45c30286 100644 --- a/docs/reference/gtk/gtk-docs.sgml +++ b/docs/reference/gtk/gtk-docs.sgml @@ -274,12 +274,6 @@ - - Cross-process Embedding - - - - Recently Used Documents diff --git a/docs/reference/gtk/gtk4-sections.txt b/docs/reference/gtk/gtk4-sections.txt index b3155a68ca..4c613dbb5e 100644 --- a/docs/reference/gtk/gtk4-sections.txt +++ b/docs/reference/gtk/gtk4-sections.txt @@ -2677,29 +2677,6 @@ GTK_PLACES_SIDEBAR_GET_CLASS gtk_places_sidebar_get_type -
-gtkplug -GtkPlug -GtkPlug -gtk_plug_construct -gtk_plug_construct_for_display -gtk_plug_new -gtk_plug_new_for_display -gtk_plug_get_id -gtk_plug_get_embedded -gtk_plug_get_socket_window - -GTK_PLUG -GTK_IS_PLUG -GTK_TYPE_PLUG -GTK_PLUG_CLASS -GTK_IS_PLUG_CLASS -GTK_PLUG_GET_CLASS - -GtkPlugPrivate -gtk_plug_get_type -
-
gtkprogressbar GtkProgressBar @@ -3345,26 +3322,6 @@ GtkSizeGroupPrivate gtk_size_group_get_type
-
-gtksocket -GtkSocket -GtkSocket -gtk_socket_new -gtk_socket_add_id -gtk_socket_get_id -gtk_socket_get_plug_window - -GTK_SOCKET -GTK_IS_SOCKET -GTK_TYPE_SOCKET -GTK_SOCKET_CLASS -GTK_IS_SOCKET_CLASS -GTK_SOCKET_GET_CLASS - -GtkSocketPrivate -gtk_socket_get_type -
-
gtkspinbutton GtkSpinButton diff --git a/docs/reference/gtk/gtk4.types.in b/docs/reference/gtk/gtk4.types.in index 54bc1194b3..922a902d43 100644 --- a/docs/reference/gtk/gtk4.types.in +++ b/docs/reference/gtk/gtk4.types.in @@ -1,4 +1,3 @@ -#include #include gtk_about_dialog_get_type @@ -138,7 +137,6 @@ gtk_page_setup_get_type gtk_paned_get_type gtk_paper_size_get_type gtk_places_sidebar_get_type -@ENABLE_ON_X11@gtk_plug_get_type gtk_popover_get_type gtk_popover_menu_get_type @DISABLE_ON_W32@gtk_printer_get_type @@ -179,7 +177,6 @@ gtk_shortcuts_section_get_type gtk_shortcuts_group_get_type gtk_shortcuts_shortcut_get_type gtk_size_group_get_type -@ENABLE_ON_X11@gtk_socket_get_type gtk_spin_button_get_type gtk_spinner_get_type gtk_stack_get_type diff --git a/docs/reference/gtk/x11.sgml b/docs/reference/gtk/x11.sgml index 5039e8a7ed..6a74ed528c 100644 --- a/docs/reference/gtk/x11.sgml +++ b/docs/reference/gtk/x11.sgml @@ -31,13 +31,6 @@ see GDK X Window System interaction in the GDK manual. - -GTK+ includes an cross-process embedding facility in the form of -the #GtkSocket and #GtkPlug widgets. These are X11-specific, and -you have to include the gtk/gtkx.h header -to use them. - - X11-specific commandline options diff --git a/gtk/Makefile.am b/gtk/Makefile.am index 4200a73759..8e5f0daf75 100644 --- a/gtk/Makefile.am +++ b/gtk/Makefile.am @@ -122,8 +122,6 @@ include $(srcdir)/inspector/Makefile.inc gtk_public_h_sources = \ gtk.h \ gtk-autocleanups.h \ - gtkx.h \ - gtkx-autocleanups.h \ gtk-a11y.h \ gtkaboutdialog.h \ gtkaccelgroup.h \ @@ -255,7 +253,6 @@ gtk_public_h_sources = \ gtkpaned.h \ gtkpapersize.h \ gtkplacessidebar.h \ - gtkplug.h \ gtkpopover.h \ gtkpopovermenu.h \ gtkprintcontext.h \ @@ -296,7 +293,6 @@ gtk_public_h_sources = \ gtkstacksidebar.h \ gtksizegroup.h \ gtksizerequest.h \ - gtksocket.h \ gtkspinbutton.h \ gtkspinner.h \ gtkstack.h \ @@ -555,7 +551,6 @@ gtk_private_h_sources = \ gtksidebarrowprivate.h \ gtksizegroup-private.h \ gtksizerequestcacheprivate.h \ - gtksocketprivate.h \ gtkstyleanimationprivate.h \ gtkstylecascadeprivate.h \ gtkstylecontextprivate.h \ @@ -1020,9 +1015,6 @@ gtk_c_sources += $(gtk_os_win32_c_sources) endif gtk_use_x11_c_sources = \ - gtkplug.c \ - gtksocket.c \ - gtkxembed.c \ gtkapplication-x11.c \ gtkmountoperation-x11.c @@ -1033,8 +1025,6 @@ gtk_use_wayland_or_x11_c_sources = \ gtkapplication-dbus.c gtk_use_win32_c_sources = \ - gtkwin32embed.c \ - gtkwin32embedwidget.c \ gtkmountoperation-stub.c gtk_use_quartz_c_sources = \ gtksearchenginequartz.c \ @@ -1044,12 +1034,8 @@ gtk_use_quartz_c_sources = \ gtkquartz.c gtk_use_stub_c_sources = \ gtkmountoperation-stub.c -gtk_use_x11_private_h_sources = \ - gtkxembed.h \ - xembed.h if USE_X11 gtk_c_sources += $(gtk_use_x11_c_sources) -gtk_private_h_sources += $(gtk_use_x11_private_h_sources) endif if USE_WAYLAND @@ -1066,12 +1052,8 @@ else endif endif -gtk_use_win32_private_h_sources = \ - gtkwin32embed.h \ - gtkwin32embedwidget.h if USE_WIN32 gtk_c_sources += $(gtk_use_win32_c_sources) -gtk_private_h_sources += $(gtk_use_win32_private_h_sources) endif gtk_use_quartz_private_h_sources = \ @@ -1087,8 +1069,6 @@ gtk_all_private_h_sources = \ $(a11y_private_h_sources) \ $(deprecated_private_h_sources) \ $(gtk_private_h_sources) \ - $(gtk_use_x11_private_h_sources) \ - $(gtk_use_win32_private_h_sources) \ $(gtk_use_quartz_private_h_sources) if !USE_X11 @@ -1380,12 +1360,12 @@ gtkprivatetypebuiltins.c: $(gtk_private_type_h_sources) gtkprivatetypebuiltins. gtktypefuncs.c: stamp-gtktypebuiltins.h stamp-gtkprivatetypebuiltins.h $(top_srcdir)/gtk/*.h $(top_srcdir)/gtk/a11y/*.h $(top_srcdir)/gtk/deprecated/*.h $(top_srcdir)/gdk/*.h Makefile - $(AM_V_GEN) (echo '#undef GTK_COMPILATION' && echo '#include ') > xgen-gtfsrc.c && \ + $(AM_V_GEN) (echo '#undef GTK_COMPILATION' && echo '#include ') > xgen-gtfsrc.c && \ echo 'G_GNUC_BEGIN_IGNORE_DEPRECATIONS' > xgen-gtf && \ ${CPP} $(DEFS) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) xgen-gtfsrc.c | \ $(GREP) -o '\bg[td]k_[a-zA-Z0-9_]*_get_type\b' | \ sort | uniq | \ - $(SED) '{ s/^/*tp++ = /; s/$$/();/; s/^.*\(gdk_x11\|gtk_plug_\|gtk_socket_\).*$$/#ifdef GDK_WINDOWING_X11\n&\n#endif/; }' >> xgen-gtf \ + $(SED) '{ s/^/*tp++ = /; s/$$/();/; s/^.*\(gdk_x11\).*$$/#ifdef GDK_WINDOWING_X11\n&\n#endif/; }' >> xgen-gtf \ && cp xgen-gtf $@ && rm -f xgen-gtf gtktestutils.c: gtktypefuncs.c @@ -1527,7 +1507,7 @@ distclean-local: fi if HAVE_INTROSPECTION -introspected_pub_headers = $(filter-out %private.h gtktextdisplay.h gtktextlayout.h gtkx.h, $(gtkinclude_HEADERS) $(a11yinclude_HEADERS) $(deprecatedinclude_HEADERS)) +introspected_pub_headers = $(filter-out %private.h gtktextdisplay.h gtktextlayout.h, $(gtkinclude_HEADERS) $(a11yinclude_HEADERS) $(deprecatedinclude_HEADERS)) introspection_files = \ $(introspected_pub_headers) \ @@ -1536,12 +1516,6 @@ introspection_files = \ gtktypebuiltins.h \ gtktypebuiltins.c -if USE_X11 -introspection_files += \ - gtksocket.c \ - gtkplug.c -endif - include $(INTROSPECTION_MAKEFILE) INTROSPECTION_SCANNER_ENV = CC="$(CC)" INTROSPECTION_COMPILER_ARGS = \ @@ -1686,9 +1660,6 @@ EXTRA_DIST += \ libgtk3.manifest.in \ gtk-win32.rc.body.in \ gtk-win32.rc.body \ - gtkwin32embed.h \ - gtkwin32embedwidget.h \ - gtkwin32embedwidget.c \ gtkprint-win32.h \ gtkprint-win32.c \ gtksearchenginequartz.h \ diff --git a/gtk/a11y/gtkaccessibility.c b/gtk/a11y/gtkaccessibility.c index 7f0e5207d9..9fc1ed6fd5 100644 --- a/gtk/a11y/gtkaccessibility.c +++ b/gtk/a11y/gtkaccessibility.c @@ -33,7 +33,6 @@ #include #include #include -#include #include #include @@ -254,17 +253,6 @@ gail_focus_watcher (GSignalInvocationHint *ihint, } } -#ifdef GDK_WINDOWING_X11 - /* - * If the focus widget is a GtkSocket without a plug - * then ignore the focus notification as the embedded - * plug will report a focus notification. - */ - if (GTK_IS_SOCKET (widget) && - gtk_socket_get_plug_window (GTK_SOCKET (widget)) != NULL) - return TRUE; -#endif - /* * The widget may not yet be visible on the screen so we wait until it is. */ diff --git a/gtk/a11y/gtktoplevelaccessible.c b/gtk/a11y/gtktoplevelaccessible.c index 4daeab4140..b925f30df2 100644 --- a/gtk/a11y/gtktoplevelaccessible.c +++ b/gtk/a11y/gtktoplevelaccessible.c @@ -26,7 +26,6 @@ #include #include #include -#include #include #include "gtktoplevelaccessible.h" @@ -208,9 +207,6 @@ show_event_watcher (GSignalInvocationHint *ihint, widget = GTK_WIDGET (object); if (gtk_widget_get_parent (widget) || is_attached_menu_window (widget) || -#ifdef GDK_WINDOWING_X11 - GTK_IS_PLUG (widget) || -#endif is_combo_window (widget)) return TRUE; @@ -270,9 +266,6 @@ gtk_toplevel_accessible_init (GtkToplevelAccessible *toplevel) if (!window || !gtk_widget_get_visible (widget) || is_attached_menu_window (widget) || -#ifdef GDK_WINDOWING_X11 - GTK_IS_PLUG (window) || -#endif gtk_widget_get_parent (GTK_WIDGET (window))) { GList *temp_l = l->next; diff --git a/gtk/gtkdnd.c b/gtk/gtkdnd.c index c9f34e2229..10c0bd804b 100644 --- a/gtk/gtkdnd.c +++ b/gtk/gtkdnd.c @@ -54,7 +54,6 @@ #include "gtkimageprivate.h" #include "gtkintl.h" #include "gtkmain.h" -#include "gtkplug.h" #include "gtktooltipprivate.h" #include "gtkwindow.h" #include "gtkrender.h" @@ -1067,18 +1066,7 @@ _gtk_drag_dest_handle_event (GtkWidget *toplevel, window = gtk_widget_get_window (toplevel); -#ifdef GDK_WINDOWING_X11 - /* Hackaround for: http://bugzilla.gnome.org/show_bug.cgi?id=136112 - * - * Currently gdk_window_get_position doesn't provide reliable - * information for embedded windows, so we call the much more - * expensive gdk_window_get_origin(). - */ - if (GTK_IS_PLUG (toplevel)) - gdk_window_get_origin (window, &tx, &ty); - else -#endif /* GDK_WINDOWING_X11 */ - gdk_window_get_position (window, &tx, &ty); + gdk_window_get_position (window, &tx, &ty); found = gtk_drag_find_widget (toplevel, context, diff --git a/gtk/gtkplug.c b/gtk/gtkplug.c deleted file mode 100644 index de56b4234d..0000000000 --- a/gtk/gtkplug.c +++ /dev/null @@ -1,1401 +0,0 @@ -/* GTK - The GIMP Toolkit - * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library. If not, see .Free - */ - -/* By Owen Taylor 98/4/4 */ - -/* - * Modified by the GTK+ Team and others 1997-2000. See the AUTHORS - * file for a list of people on the GTK+ Team. See the ChangeLog - * files for a list of changes. These files are distributed with - * GTK+ at ftp://ftp.gtk.org/pub/gtk/. - */ - -#include "config.h" - -#include "gtkdebug.h" -#include "gtkmain.h" -#include "gtkmarshalers.h" -#include "gtkplug.h" -#include "gtkintl.h" -#include "gtkprivate.h" -#include "gtkrender.h" -#include "gtksocketprivate.h" -#include "gtkwidgetprivate.h" -#include "gtkwindowgroup.h" -#include "gtkwindowprivate.h" -#include "gtkxembed.h" - -#include - -/** - * SECTION:gtkplug - * @Short_description: Toplevel for embedding into other processes - * @Title: GtkPlug - * @include: gtk/gtkx.h - * @See_also: #GtkSocket - * - * Together with #GtkSocket, #GtkPlug provides the ability to embed - * widgets from one process into another process in a fashion that is - * transparent to the user. One process creates a #GtkSocket widget - * and passes the ID of that widget’s window to the other process, - * which then creates a #GtkPlug with that window ID. Any widgets - * contained in the #GtkPlug then will appear inside the first - * application’s window. - * - * The communication between a #GtkSocket and a #GtkPlug follows the - * [XEmbed Protocol](http://www.freedesktop.org/Standards/xembed-spec). - * This protocol has also been implemented in other toolkits, e.g. Qt, - * allowing the same level of integration when embedding a Qt widget - * in GTK+ or vice versa. - * - * The #GtkPlug and #GtkSocket widgets are only available when GTK+ - * is compiled for the X11 platform and %GDK_WINDOWING_X11 is defined. - * They can only be used on a #GdkX11Display. To use #GtkPlug and - * #GtkSocket, you need to include the `gtk/gtkx.h` header. - */ - -struct _GtkPlugPrivate -{ - GtkWidget *modality_window; - GtkWindowGroup *modality_group; - - GdkWindow *socket_window; - - GHashTable *grabbed_keys; - - guint same_app : 1; -}; - -static void gtk_plug_get_property (GObject *object, - guint prop_id, - GValue *value, - GParamSpec *pspec); -static void gtk_plug_finalize (GObject *object); -static void gtk_plug_realize (GtkWidget *widget); -static void gtk_plug_unrealize (GtkWidget *widget); -static void gtk_plug_show (GtkWidget *widget); -static void gtk_plug_hide (GtkWidget *widget); -static void gtk_plug_map (GtkWidget *widget); -static void gtk_plug_unmap (GtkWidget *widget); -static gboolean gtk_plug_key_press_event (GtkWidget *widget, - GdkEventKey *event); -static gboolean gtk_plug_focus_event (GtkWidget *widget, - GdkEventFocus *event); -static void gtk_plug_set_focus (GtkWindow *window, - GtkWidget *focus); -static gboolean gtk_plug_focus (GtkWidget *widget, - GtkDirectionType direction); -static void gtk_plug_check_resize (GtkContainer *container); -static void gtk_plug_keys_changed (GtkWindow *window); - -static void xembed_set_info (GdkWindow *window, - unsigned long flags); - -static GtkBinClass *bin_class = NULL; - -typedef struct -{ - guint accelerator_key; - GdkModifierType accelerator_mods; -} GrabbedKey; - -enum { - PROP_0, - PROP_EMBEDDED, - PROP_SOCKET_WINDOW -}; - -enum { - EMBEDDED, - LAST_SIGNAL -}; - -static guint plug_signals[LAST_SIGNAL] = { 0 }; - -G_DEFINE_TYPE_WITH_PRIVATE (GtkPlug, gtk_plug, GTK_TYPE_WINDOW) - -static void -gtk_plug_get_property (GObject *object, - guint prop_id, - GValue *value, - GParamSpec *pspec) -{ - GtkPlug *plug = GTK_PLUG (object); - GtkPlugPrivate *priv = plug->priv; - - switch (prop_id) - { - case PROP_EMBEDDED: - g_value_set_boolean (value, priv->socket_window != NULL); - break; - case PROP_SOCKET_WINDOW: - g_value_set_object (value, priv->socket_window); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - -static void -gtk_plug_class_init (GtkPlugClass *class) -{ - GObjectClass *gobject_class = (GObjectClass *)class; - GtkWidgetClass *widget_class = (GtkWidgetClass *)class; - GtkWindowClass *window_class = (GtkWindowClass *)class; - GtkContainerClass *container_class = (GtkContainerClass *)class; - - bin_class = g_type_class_peek (GTK_TYPE_BIN); - - gobject_class->get_property = gtk_plug_get_property; - gobject_class->finalize = gtk_plug_finalize; - - widget_class->realize = gtk_plug_realize; - widget_class->unrealize = gtk_plug_unrealize; - widget_class->key_press_event = gtk_plug_key_press_event; - widget_class->focus_in_event = gtk_plug_focus_event; - widget_class->focus_out_event = gtk_plug_focus_event; - - widget_class->show = gtk_plug_show; - widget_class->hide = gtk_plug_hide; - widget_class->map = gtk_plug_map; - widget_class->unmap = gtk_plug_unmap; - widget_class->focus = gtk_plug_focus; - - gtk_widget_class_set_accessible_role (widget_class, ATK_ROLE_PANEL); - - container_class->check_resize = gtk_plug_check_resize; - - window_class->set_focus = gtk_plug_set_focus; - window_class->keys_changed = gtk_plug_keys_changed; - - /** - * GtkPlug:embedded: - * - * %TRUE if the plug is embedded in a socket. - * - * Since: 2.12 - */ - g_object_class_install_property (gobject_class, - PROP_EMBEDDED, - g_param_spec_boolean ("embedded", - P_("Embedded"), - P_("Whether the plug is embedded"), - FALSE, - GTK_PARAM_READABLE)); - - /** - * GtkPlug:socket-window: - * - * The window of the socket the plug is embedded in. - * - * Since: 2.14 - */ - g_object_class_install_property (gobject_class, - PROP_SOCKET_WINDOW, - g_param_spec_object ("socket-window", - P_("Socket Window"), - P_("The window of the socket the plug is embedded in"), - GDK_TYPE_WINDOW, - GTK_PARAM_READABLE)); - - /** - * GtkPlug::embedded: - * @plug: the object on which the signal was emitted - * - * Gets emitted when the plug becomes embedded in a socket. - */ - plug_signals[EMBEDDED] = - g_signal_new (I_("embedded"), - G_OBJECT_CLASS_TYPE (class), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (GtkPlugClass, embedded), - NULL, NULL, - NULL, - G_TYPE_NONE, 0); -} - -static void -gtk_plug_init (GtkPlug *plug) -{ - plug->priv = gtk_plug_get_instance_private (plug); - - gtk_window_set_decorated (GTK_WINDOW (plug), FALSE); -} - -/** - * gtk_plug_handle_modality_on: - * @plug: a #GtkPlug - * - * Called from the GtkPlug backend when the corresponding socket has - * told the plug that it modality has toggled on. - */ -static void -gtk_plug_handle_modality_on (GtkPlug *plug) -{ - GtkPlugPrivate *priv = plug->priv; - - if (!priv->modality_window) - { - priv->modality_window = gtk_window_new (GTK_WINDOW_POPUP); - gtk_window_set_screen (GTK_WINDOW (priv->modality_window), - gtk_widget_get_screen (GTK_WIDGET (plug))); - gtk_widget_realize (priv->modality_window); - gtk_window_group_add_window (priv->modality_group, GTK_WINDOW (priv->modality_window)); - gtk_grab_add (priv->modality_window); - } -} - -/** - * gtk_plug_handle_modality_off: - * @plug: a #GtkPlug - * - * Called from the GtkPlug backend when the corresponding socket has - * told the plug that it modality has toggled off. - */ -static void -gtk_plug_handle_modality_off (GtkPlug *plug) -{ - GtkPlugPrivate *priv = plug->priv; - - if (priv->modality_window) - { - gtk_widget_destroy (priv->modality_window); - priv->modality_window = NULL; - } -} - -static void -gtk_plug_set_is_child (GtkPlug *plug, - gboolean is_child) -{ - GtkPlugPrivate *priv = plug->priv; - GtkWidget *widget = GTK_WIDGET (plug); - - g_assert (!gtk_widget_get_parent (widget)); - - if (is_child) - { - if (priv->modality_window) - gtk_plug_handle_modality_off (plug); - - if (priv->modality_group) - { - gtk_window_group_remove_window (priv->modality_group, GTK_WINDOW (plug)); - g_object_unref (priv->modality_group); - priv->modality_group = NULL; - } - - /* As a toplevel, the MAPPED flag doesn't correspond - * to whether the widget->window is mapped; we unmap - * here, but don't bother remapping -- we will get mapped - * by gtk_widget_set_parent (). - */ - if (gtk_widget_get_mapped (widget)) - gtk_widget_unmap (widget); - - _gtk_window_set_is_toplevel (GTK_WINDOW (plug), FALSE); - G_GNUC_BEGIN_IGNORE_DEPRECATIONS; - gtk_container_set_resize_mode (GTK_CONTAINER (plug), GTK_RESIZE_PARENT); - G_GNUC_END_IGNORE_DEPRECATIONS; - - _gtk_widget_propagate_hierarchy_changed (widget, widget); - } - else - { - if (gtk_window_get_focus (GTK_WINDOW (plug))) - gtk_window_set_focus (GTK_WINDOW (plug), NULL); - if (gtk_window_get_default_widget (GTK_WINDOW (plug))) - gtk_window_set_default (GTK_WINDOW (plug), NULL); - - priv->modality_group = gtk_window_group_new (); - gtk_window_group_add_window (priv->modality_group, GTK_WINDOW (plug)); - - _gtk_window_set_is_toplevel (GTK_WINDOW (plug), TRUE); - G_GNUC_BEGIN_IGNORE_DEPRECATIONS; - gtk_container_set_resize_mode (GTK_CONTAINER (plug), GTK_RESIZE_QUEUE); - G_GNUC_END_IGNORE_DEPRECATIONS; - - _gtk_widget_propagate_hierarchy_changed (GTK_WIDGET (plug), NULL); - } -} - -/** - * gtk_plug_get_id: - * @plug: a #GtkPlug. - * - * Gets the window ID of a #GtkPlug widget, which can then - * be used to embed this window inside another window, for - * instance with gtk_socket_add_id(). - * - * Returns: the window ID for the plug - **/ -Window -gtk_plug_get_id (GtkPlug *plug) -{ - g_return_val_if_fail (GTK_IS_PLUG (plug), 0); - - if (!gtk_widget_get_realized (GTK_WIDGET (plug))) - gtk_widget_realize (GTK_WIDGET (plug)); - - return GDK_WINDOW_XID (gtk_widget_get_window (GTK_WIDGET (plug))); -} - -/** - * gtk_plug_get_embedded: - * @plug: a #GtkPlug - * - * Determines whether the plug is embedded in a socket. - * - * Returns: %TRUE if the plug is embedded in a socket - * - * Since: 2.14 - **/ -gboolean -gtk_plug_get_embedded (GtkPlug *plug) -{ - g_return_val_if_fail (GTK_IS_PLUG (plug), FALSE); - - return plug->priv->socket_window != NULL; -} - -/** - * gtk_plug_get_socket_window: - * @plug: a #GtkPlug - * - * Retrieves the socket the plug is embedded in. - * - * Returns: (nullable) (transfer none): the window of the socket, or %NULL - * - * Since: 2.14 - **/ -GdkWindow * -gtk_plug_get_socket_window (GtkPlug *plug) -{ - g_return_val_if_fail (GTK_IS_PLUG (plug), NULL); - - return plug->priv->socket_window; -} - -/** - * _gtk_plug_add_to_socket: - * @plug: a #GtkPlug - * @socket_: a #GtkSocket - * - * Adds a plug to a socket within the same application. - **/ -void -_gtk_plug_add_to_socket (GtkPlug *plug, - GtkSocket *socket_) -{ - GtkPlugPrivate *priv; - GtkWidget *widget; - - g_return_if_fail (GTK_IS_PLUG (plug)); - g_return_if_fail (GTK_IS_SOCKET (socket_)); - g_return_if_fail (gtk_widget_get_realized (GTK_WIDGET (socket_))); - - priv = plug->priv; - widget = GTK_WIDGET (plug); - - gtk_plug_set_is_child (plug, TRUE); - priv->same_app = TRUE; - socket_->priv->same_app = TRUE; - socket_->priv->plug_widget = widget; - - priv->socket_window = gtk_widget_get_window (GTK_WIDGET (socket_)); - g_object_ref (priv->socket_window); - g_signal_emit (plug, plug_signals[EMBEDDED], 0); - g_object_notify (G_OBJECT (plug), "embedded"); - - if (gtk_widget_get_realized (widget)) - { - GdkWindow *window; - - window = gtk_widget_get_window (widget); - gdk_window_reparent (window, priv->socket_window, - -gdk_window_get_width (window), - -gdk_window_get_height (window)); - } - - gtk_widget_set_parent (widget, GTK_WIDGET (socket_)); - - g_signal_emit_by_name (socket_, "plug-added"); -} - -/* - * gtk_plug_send_delete_event: - * @widget: a #GtkWidget - * - * Send a GDK_DELETE event to the @widget and destroy it if - * necessary. Internal GTK function, called from this file or the - * backend-specific GtkPlug implementation. - */ -static void -gtk_plug_send_delete_event (GtkWidget *widget) -{ - GdkEvent *event = gdk_event_new (GDK_DELETE); - - event->any.window = g_object_ref (gtk_widget_get_window (widget)); - event->any.send_event = FALSE; - - g_object_ref (widget); - - if (!gtk_widget_event (widget, event)) - gtk_widget_destroy (widget); - - g_object_unref (widget); - - gdk_event_free (event); -} - -/** - * _gtk_plug_remove_from_socket: - * @plug: a #GtkPlug - * @socket_: a #GtkSocket - * - * Removes a plug from a socket within the same application. - **/ -void -_gtk_plug_remove_from_socket (GtkPlug *plug, - GtkSocket *socket_) -{ - GtkPlugPrivate *priv; - GtkWidget *widget; - GdkWindow *window; - GdkWindow *root_window; - gboolean result; - gboolean widget_was_visible; - - g_return_if_fail (GTK_IS_PLUG (plug)); - g_return_if_fail (GTK_IS_SOCKET (socket_)); - g_return_if_fail (gtk_widget_get_realized (GTK_WIDGET (plug))); - - priv = plug->priv; - widget = GTK_WIDGET (plug); - - if (_gtk_widget_get_in_reparent (widget)) - return; - - g_object_ref (plug); - g_object_ref (socket_); - - widget_was_visible = gtk_widget_get_visible (widget); - window = gtk_widget_get_window (widget); - root_window = gdk_screen_get_root_window (gtk_widget_get_screen (widget)); - - gdk_window_hide (window); - _gtk_widget_set_in_reparent (widget, TRUE); - gdk_window_reparent (window, root_window, 0, 0); - gtk_widget_unparent (GTK_WIDGET (plug)); - _gtk_widget_set_in_reparent (widget, FALSE); - - socket_->priv->plug_widget = NULL; - if (socket_->priv->plug_window != NULL) - { - g_object_unref (socket_->priv->plug_window); - socket_->priv->plug_window = NULL; - } - - socket_->priv->same_app = FALSE; - - priv->same_app = FALSE; - if (priv->socket_window != NULL) - { - g_object_unref (priv->socket_window); - priv->socket_window = NULL; - } - gtk_plug_set_is_child (plug, FALSE); - - g_signal_emit_by_name (socket_, "plug-removed", &result); - if (!result) - gtk_widget_destroy (GTK_WIDGET (socket_)); - - if (window) - gtk_plug_send_delete_event (widget); - - g_object_unref (plug); - - if (widget_was_visible && gtk_widget_get_visible (GTK_WIDGET (socket_))) - gtk_widget_queue_resize (GTK_WIDGET (socket_)); - - g_object_unref (socket_); -} - -/** - * gtk_plug_construct: - * @plug: a #GtkPlug. - * @socket_id: the XID of the socket’s window. - * - * Finish the initialization of @plug for a given #GtkSocket identified by - * @socket_id. This function will generally only be used by classes deriving from #GtkPlug. - **/ -void -gtk_plug_construct (GtkPlug *plug, - Window socket_id) -{ - gtk_plug_construct_for_display (plug, gdk_display_get_default (), socket_id); -} - -/** - * gtk_plug_construct_for_display: - * @plug: a #GtkPlug. - * @display: the #GdkDisplay associated with @socket_id’s - * #GtkSocket. - * @socket_id: the XID of the socket’s window. - * - * Finish the initialization of @plug for a given #GtkSocket identified by - * @socket_id which is currently displayed on @display. - * This function will generally only be used by classes deriving from #GtkPlug. - * - * Since: 2.2 - **/ -void -gtk_plug_construct_for_display (GtkPlug *plug, - GdkDisplay *display, - Window socket_id) -{ - GtkPlugPrivate *priv; - - g_return_if_fail (GTK_IS_PLUG (plug)); - g_return_if_fail (GDK_IS_DISPLAY (display)); - - priv = plug->priv; - - if (socket_id) - { - gpointer user_data = NULL; - - if (GDK_IS_X11_DISPLAY (display)) - priv->socket_window = gdk_x11_window_lookup_for_display (display, socket_id); - else - priv->socket_window = NULL; - - if (priv->socket_window) - { - gdk_window_get_user_data (priv->socket_window, &user_data); - - if (user_data) - { - if (GTK_IS_SOCKET (user_data)) - _gtk_plug_add_to_socket (plug, user_data); - else - { - g_warning (G_STRLOC "Can't create GtkPlug as child of non-GtkSocket"); - priv->socket_window = NULL; - } - } - else - g_object_ref (priv->socket_window); - } - else if (GDK_IS_X11_DISPLAY (display)) - priv->socket_window = gdk_x11_window_foreign_new_for_display (display, socket_id); - - if (priv->socket_window) { - g_signal_emit (plug, plug_signals[EMBEDDED], 0); - - g_object_notify (G_OBJECT (plug), "embedded"); - } - } -} - -/** - * gtk_plug_new: - * @socket_id: the window ID of the socket, or 0. - * - * Creates a new plug widget inside the #GtkSocket identified - * by @socket_id. If @socket_id is 0, the plug is left “unplugged” and - * can later be plugged into a #GtkSocket by gtk_socket_add_id(). - * - * Returns: the new #GtkPlug widget. - **/ -GtkWidget* -gtk_plug_new (Window socket_id) -{ - return gtk_plug_new_for_display (gdk_display_get_default (), socket_id); -} - -/** - * gtk_plug_new_for_display: - * @display: the #GdkDisplay on which @socket_id is displayed - * @socket_id: the XID of the socket’s window. - * - * Create a new plug widget inside the #GtkSocket identified by socket_id. - * - * Returns: the new #GtkPlug widget. - * - * Since: 2.2 - */ -GtkWidget* -gtk_plug_new_for_display (GdkDisplay *display, - Window socket_id) -{ - GtkPlug *plug; - - g_return_val_if_fail (GDK_IS_DISPLAY (display), NULL); - - plug = g_object_new (GTK_TYPE_PLUG, NULL); - gtk_plug_construct_for_display (plug, display, socket_id); - return GTK_WIDGET (plug); -} - -static void -gtk_plug_finalize (GObject *object) -{ - GtkPlug *plug = GTK_PLUG (object); - GtkPlugPrivate *priv = plug->priv; - - if (priv->grabbed_keys) - g_hash_table_destroy (priv->grabbed_keys); - - G_OBJECT_CLASS (gtk_plug_parent_class)->finalize (object); -} - -static void -gtk_plug_unrealize (GtkWidget *widget) -{ - GtkPlug *plug = GTK_PLUG (widget); - GtkPlugPrivate *priv = plug->priv; - - if (priv->socket_window != NULL) - { - g_object_unref (priv->socket_window); - priv->socket_window = NULL; - - g_object_notify (G_OBJECT (widget), "embedded"); - } - - if (!priv->same_app) - { - if (priv->modality_window) - gtk_plug_handle_modality_off (plug); - - gtk_window_group_remove_window (priv->modality_group, GTK_WINDOW (plug)); - g_object_unref (priv->modality_group); - } - - GTK_WIDGET_CLASS (gtk_plug_parent_class)->unrealize (widget); -} - -static void -xembed_set_info (GdkWindow *window, - unsigned long flags) -{ - GdkDisplay *display = gdk_window_get_display (window); - unsigned long buffer[2]; - - Atom xembed_info_atom = gdk_x11_get_xatom_by_name_for_display (display, "_XEMBED_INFO"); - - buffer[0] = GTK_XEMBED_PROTOCOL_VERSION; - buffer[1] = flags; - - XChangeProperty (GDK_DISPLAY_XDISPLAY (display), - GDK_WINDOW_XID (window), - xembed_info_atom, xembed_info_atom, 32, - PropModeReplace, - (unsigned char *)buffer, 2); -} - -/** - * gtk_plug_focus_first_last: - * @plug: a #GtkPlug - * @direction: a direction - * - * Called from the GtkPlug backend when the corresponding socket has - * told the plug that it has received the focus. - */ -static void -gtk_plug_focus_first_last (GtkPlug *plug, - GtkDirectionType direction) -{ - GtkWindow *window = GTK_WINDOW (plug); - GtkWidget *focus_widget; - GtkWidget *parent; - - focus_widget = gtk_window_get_focus (window); - if (focus_widget) - { - parent = gtk_widget_get_parent (focus_widget); - while (parent) - { - gtk_container_set_focus_child (GTK_CONTAINER (parent), NULL); - parent = gtk_widget_get_parent (parent); - } - - gtk_window_set_focus (GTK_WINDOW (plug), NULL); - } - - gtk_widget_child_focus (GTK_WIDGET (plug), direction); -} - -static void -handle_xembed_message (GtkPlug *plug, - XEmbedMessageType message, - glong detail, - glong data1, - glong data2, - guint32 time) -{ - GtkWindow *window = GTK_WINDOW (plug); - - GTK_NOTE (PLUGSOCKET, - g_message ("GtkPlug: %s received", _gtk_xembed_message_name (message))); - - switch (message) - { - case XEMBED_EMBEDDED_NOTIFY: - break; - case XEMBED_WINDOW_ACTIVATE: - _gtk_window_set_is_active (window, TRUE); - break; - case XEMBED_WINDOW_DEACTIVATE: - _gtk_window_set_is_active (window, FALSE); - break; - - case XEMBED_MODALITY_ON: - gtk_plug_handle_modality_on (plug); - break; - case XEMBED_MODALITY_OFF: - gtk_plug_handle_modality_off (plug); - break; - - case XEMBED_FOCUS_IN: - _gtk_window_set_has_toplevel_focus (window, TRUE); - switch (detail) - { - case XEMBED_FOCUS_FIRST: - gtk_plug_focus_first_last (plug, GTK_DIR_TAB_FORWARD); - break; - case XEMBED_FOCUS_LAST: - gtk_plug_focus_first_last (plug, GTK_DIR_TAB_BACKWARD); - break; - case XEMBED_FOCUS_CURRENT: - break; - } - break; - - case XEMBED_FOCUS_OUT: - _gtk_window_set_has_toplevel_focus (window, FALSE); - break; - - case XEMBED_GRAB_KEY: - case XEMBED_UNGRAB_KEY: - case XEMBED_GTK_GRAB_KEY: - case XEMBED_GTK_UNGRAB_KEY: - case XEMBED_REQUEST_FOCUS: - case XEMBED_FOCUS_NEXT: - case XEMBED_FOCUS_PREV: - g_warning ("GtkPlug: Invalid _XEMBED message %s received", _gtk_xembed_message_name (message)); - break; - - default: - GTK_NOTE(PLUGSOCKET, - g_message ("GtkPlug: Ignoring unknown _XEMBED message of type %d", message)); - break; - } -} -static GdkFilterReturn -gtk_plug_filter_func (GdkXEvent *gdk_xevent, - GdkEvent *event, - gpointer data) -{ - GdkScreen *screen = gdk_window_get_screen (event->any.window); - GdkDisplay *display = gdk_screen_get_display (screen); - GtkPlug *plug = GTK_PLUG (data); - GtkPlugPrivate *priv = plug->priv; - XEvent *xevent = (XEvent *)gdk_xevent; - GHashTableIter iter; - gpointer key; - GdkFilterReturn return_val; - - return_val = GDK_FILTER_CONTINUE; - - switch (xevent->type) - { - case ClientMessage: - if (xevent->xclient.message_type == gdk_x11_get_xatom_by_name_for_display (display, "_XEMBED")) - { - _gtk_xembed_push_message (xevent); - handle_xembed_message (plug, - xevent->xclient.data.l[1], - xevent->xclient.data.l[2], - xevent->xclient.data.l[3], - xevent->xclient.data.l[4], - xevent->xclient.data.l[0]); - _gtk_xembed_pop_message (); - - return_val = GDK_FILTER_REMOVE; - } - else if (xevent->xclient.message_type == gdk_x11_get_xatom_by_name_for_display (display, "WM_DELETE_WINDOW")) - { - /* We filter these out because we take being reparented back to the - * root window as the reliable end of the embedding protocol - */ - - return_val = GDK_FILTER_REMOVE; - } - break; - case ReparentNotify: - { - XReparentEvent *xre = &xevent->xreparent; - gboolean was_embedded = priv->socket_window != NULL; - - GTK_NOTE (PLUGSOCKET, g_message("GtkPlug: ReparentNotify received")); - - return_val = GDK_FILTER_REMOVE; - - g_object_ref (plug); - - if (was_embedded) - { - /* End of embedding protocol for previous socket */ - - GTK_NOTE (PLUGSOCKET, g_message ("GtkPlug: end of embedding")); - /* FIXME: race if we remove from another socket and - * then add to a local window before we get notification - * Probably need check in _gtk_plug_add_to_socket - */ - - if (xre->parent != GDK_WINDOW_XID (priv->socket_window)) - { - GtkWidget *widget = GTK_WIDGET (plug); - - g_object_unref (priv->socket_window); - priv->socket_window = NULL; - - /* Emit a delete window, as if the user attempted - * to close the toplevel. Simple as to how we - * handle WM_DELETE_WINDOW, if it isn't handled - * we destroy the widget. BUt only do this if - * we are being reparented to the root window. - * Moving from one embedder to another should - * be invisible to the app. - */ - - if (xre->parent == GDK_WINDOW_XID (gdk_screen_get_root_window (screen))) - { - GTK_NOTE (PLUGSOCKET, g_message ("GtkPlug: calling gtk_plug_send_delete_event()")); - gtk_plug_send_delete_event (widget); - - g_object_notify (G_OBJECT (plug), "embedded"); - } - } - else - goto done; - } - - if (xre->parent != GDK_WINDOW_XID (gdk_screen_get_root_window (screen))) - { - /* Start of embedding protocol */ - - GTK_NOTE (PLUGSOCKET, g_message ("GtkPlug: start of embedding")); - - priv->socket_window = gdk_x11_window_lookup_for_display (display, xre->parent); - if (priv->socket_window) - { - gpointer user_data = NULL; - gdk_window_get_user_data (priv->socket_window, &user_data); - - if (user_data) - { - g_warning (G_STRLOC "Plug reparented unexpectedly into window in the same process"); - priv->socket_window = NULL; - break; /* FIXME: shouldn't this unref the plug? i.e. "goto done;" instead */ - } - - g_object_ref (priv->socket_window); - } - else - { - priv->socket_window = gdk_x11_window_foreign_new_for_display (display, xre->parent); - if (!priv->socket_window) /* Already gone */ - break; /* FIXME: shouldn't this unref the plug? i.e. "goto done;" instead */ - } - - if (priv->grabbed_keys) - { - g_hash_table_iter_init (&iter, priv->grabbed_keys); - while (g_hash_table_iter_next (&iter, &key, NULL)) - { - GrabbedKey *grabbed_key = key; - - _gtk_xembed_send_message (priv->socket_window, XEMBED_GTK_GRAB_KEY, 0, - grabbed_key->accelerator_key, - grabbed_key->accelerator_mods); - } - } - - if (!was_embedded) - g_signal_emit_by_name (plug, "embedded"); - - g_object_notify (G_OBJECT (plug), "embedded"); - } - - done: - g_object_unref (plug); - - break; - } - case KeyPress: - case KeyRelease: - { - GdkModifierType state, consumed; - GdkDevice *keyboard; - GdkKeymap *keymap; - GdkSeat *seat; - - if (xevent->type == KeyPress) - event->key.type = GDK_KEY_PRESS; - else - event->key.type = GDK_KEY_RELEASE; - - event->key.window = gdk_x11_window_lookup_for_display (display, xevent->xany.window); - event->key.send_event = TRUE; - event->key.time = xevent->xkey.time; - event->key.state = (GdkModifierType) xevent->xkey.state; - event->key.hardware_keycode = xevent->xkey.keycode; - event->key.keyval = GDK_KEY_VoidSymbol; - - seat = gdk_display_get_default_seat (display); - keyboard = gdk_seat_get_keyboard (seat); - gdk_event_set_device (event, keyboard); - - keymap = gdk_keymap_get_for_display (display); - - event->key.group = gdk_x11_keymap_get_group_for_state (keymap, xevent->xkey.state); - event->key.is_modifier = gdk_x11_keymap_key_is_modifier (keymap, event->key.hardware_keycode); - - gdk_keymap_translate_keyboard_state (keymap, - event->key.hardware_keycode, - event->key.state, - event->key.group, - &event->key.keyval, - NULL, NULL, &consumed); - - state = event->key.state & ~consumed; - gdk_keymap_add_virtual_modifiers (keymap, &state); - event->key.state |= state; - - event->key.length = 0; - event->key.string = g_strdup (""); - - return_val = GDK_FILTER_TRANSLATE; - } - } - - return return_val; -} -static void -gtk_plug_realize (GtkWidget *widget) -{ - GtkAllocation allocation; - GtkPlug *plug = GTK_PLUG (widget); - GtkPlugPrivate *priv = plug->priv; - GtkWindow *window = GTK_WINDOW (widget); - GdkWindow *gdk_window; - GdkWindowAttr attributes; - const gchar *title; - gint attributes_mask; - GdkScreen *screen; - - gtk_widget_set_realized (widget, TRUE); - - screen = gtk_widget_get_screen (widget); - if (!GDK_IS_X11_SCREEN (screen)) - g_warning ("GtkPlug only works under X11"); - - title = gtk_window_get_title (window); - gtk_widget_get_allocation (widget, &allocation); - - attributes.window_type = GDK_WINDOW_CHILD; /* XXX GDK_WINDOW_PLUG ? */ - attributes.title = (gchar *) title; - attributes.width = allocation.width; - attributes.height = allocation.height; - attributes.wclass = GDK_INPUT_OUTPUT; - - /* this isn't right - we should match our parent's visual/colormap. - * though that will require handling "foreign" colormaps */ - attributes.visual = gtk_widget_get_visual (widget); - attributes.event_mask = gtk_widget_get_events (widget); - attributes.event_mask |= (GDK_EXPOSURE_MASK | - GDK_KEY_PRESS_MASK | - GDK_KEY_RELEASE_MASK | - GDK_ENTER_NOTIFY_MASK | - GDK_LEAVE_NOTIFY_MASK | - GDK_STRUCTURE_MASK); - - attributes_mask = GDK_WA_VISUAL; - attributes_mask |= (title ? GDK_WA_TITLE : 0); - - if (gtk_widget_is_toplevel (widget)) - { - GdkWindow *root_window; - attributes.window_type = GDK_WINDOW_TOPLEVEL; - - root_window = gdk_screen_get_root_window (screen); - - gdk_error_trap_push (); - if (priv->socket_window) - gdk_window = gdk_window_new (priv->socket_window, - &attributes, attributes_mask); - else /* If it's a passive plug, we use the root window */ - gdk_window = gdk_window_new (root_window, - &attributes, attributes_mask); - /* Because the window isn't known to the window manager, - * frame sync won't work. In theory, XEMBED could be extended - * so that embedder did frame sync like a window manager, but - * it's just not worth the effort considering the current - * minimal use of XEMBED. - */ - gdk_x11_window_set_frame_sync_enabled (gdk_window, FALSE); - gtk_widget_set_window (widget, gdk_window); - - gdk_display_sync (gtk_widget_get_display (widget)); - if (gdk_error_trap_pop ()) /* Uh-oh */ - { - gdk_error_trap_push (); - gdk_window_destroy (gdk_window); - gdk_error_trap_pop_ignored (); - gdk_window = gdk_window_new (root_window, - &attributes, attributes_mask); - gtk_widget_set_window (widget, gdk_window); - } - - gdk_window_add_filter (gdk_window, - gtk_plug_filter_func, - widget); - - priv->modality_group = gtk_window_group_new (); - gtk_window_group_add_window (priv->modality_group, window); - - xembed_set_info (gtk_widget_get_window (GTK_WIDGET (plug)), 0); - } - else - { - gdk_window = gdk_window_new (gtk_widget_get_parent_window (widget), - &attributes, attributes_mask); - gtk_widget_set_window (widget, gdk_window); - } - - gtk_widget_register_window (widget, gdk_window); -} - -static void -gtk_plug_show (GtkWidget *widget) -{ - if (gtk_widget_is_toplevel (widget)) - GTK_WIDGET_CLASS (gtk_plug_parent_class)->show (widget); - else - GTK_WIDGET_CLASS (bin_class)->show (widget); -} - -static void -gtk_plug_hide (GtkWidget *widget) -{ - if (gtk_widget_is_toplevel (widget)) - GTK_WIDGET_CLASS (gtk_plug_parent_class)->hide (widget); - else - GTK_WIDGET_CLASS (bin_class)->hide (widget); -} - -/* From gdkprivate.h */ -void gdk_synthesize_window_state (GdkWindow *window, - GdkWindowState unset_flags, - GdkWindowState set_flags); - -static void -gtk_plug_map (GtkWidget *widget) -{ - if (gtk_widget_is_toplevel (widget)) - { - GtkBin *bin = GTK_BIN (widget); - GtkPlug *plug = GTK_PLUG (widget); - GtkWidget *child; - - gtk_widget_set_mapped (widget, TRUE); - - child = gtk_bin_get_child (bin); - if (child != NULL && - gtk_widget_get_visible (child) && - !gtk_widget_get_mapped (child)) - gtk_widget_map (child); - - xembed_set_info (gtk_widget_get_window (GTK_WIDGET (plug)), XEMBED_MAPPED); - - gdk_synthesize_window_state (gtk_widget_get_window (widget), - GDK_WINDOW_STATE_WITHDRAWN, - 0); - } - else - GTK_WIDGET_CLASS (bin_class)->map (widget); -} - -static void -gtk_plug_unmap (GtkWidget *widget) -{ - if (gtk_widget_is_toplevel (widget)) - { - GtkPlug *plug = GTK_PLUG (widget); - GdkWindow *window; - GtkWidget *child; - - window = gtk_widget_get_window (widget); - - gtk_widget_set_mapped (widget, FALSE); - - gdk_window_hide (window); - - child = gtk_bin_get_child (GTK_BIN (widget)); - if (child != NULL) - gtk_widget_unmap (child); - - xembed_set_info (gtk_widget_get_window (GTK_WIDGET (plug)), 0); - - gdk_synthesize_window_state (window, - 0, - GDK_WINDOW_STATE_WITHDRAWN); - } - else - GTK_WIDGET_CLASS (bin_class)->unmap (widget); -} - -static gboolean -gtk_plug_key_press_event (GtkWidget *widget, - GdkEventKey *event) -{ - if (gtk_widget_is_toplevel (widget)) - return GTK_WIDGET_CLASS (gtk_plug_parent_class)->key_press_event (widget, event); - else - return FALSE; -} - -static gboolean -gtk_plug_focus_event (GtkWidget *widget, - GdkEventFocus *event) -{ - /* We eat focus-in events and focus-out events, since they - * can be generated by something like a keyboard grab on - * a child of the plug. - */ - return FALSE; -} - -static void -gtk_plug_set_focus (GtkWindow *window, - GtkWidget *focus) -{ - GtkPlug *plug = GTK_PLUG (window); - GtkPlugPrivate *priv = plug->priv; - - GTK_WINDOW_CLASS (gtk_plug_parent_class)->set_focus (window, focus); - - /* Ask for focus from embedder - */ - - if (focus && !gtk_window_has_toplevel_focus (window)) - _gtk_xembed_send_message (priv->socket_window, - XEMBED_REQUEST_FOCUS, 0, 0, 0); -} - -static guint -grabbed_key_hash (gconstpointer a) -{ - const GrabbedKey *key = a; - guint h; - - h = key->accelerator_key << 16; - h ^= key->accelerator_key >> 16; - h ^= key->accelerator_mods; - - return h; -} - -static gboolean -grabbed_key_equal (gconstpointer a, gconstpointer b) -{ - const GrabbedKey *keya = a; - const GrabbedKey *keyb = b; - - return (keya->accelerator_key == keyb->accelerator_key && - keya->accelerator_mods == keyb->accelerator_mods); -} - -static void -add_grabbed_key (gpointer key, gpointer val, gpointer data) -{ - GrabbedKey *grabbed_key = key; - GtkPlug *plug = data; - GtkPlugPrivate *priv = plug->priv; - - if (!priv->grabbed_keys || - !g_hash_table_lookup (priv->grabbed_keys, grabbed_key)) - { - _gtk_xembed_send_message (priv->socket_window, XEMBED_GTK_GRAB_KEY, 0, - grabbed_key->accelerator_key, - grabbed_key->accelerator_mods); - } -} - -static void -remove_grabbed_key (gpointer key, gpointer val, gpointer data) -{ - GrabbedKey *grabbed_key = key; - GtkPlug *plug = data; - GtkPlugPrivate *priv = plug->priv; - - if (!priv->grabbed_keys || - !g_hash_table_lookup (priv->grabbed_keys, grabbed_key)) - { - _gtk_xembed_send_message (priv->socket_window, XEMBED_GTK_UNGRAB_KEY, 0, - grabbed_key->accelerator_key, - grabbed_key->accelerator_mods); - } -} - -static void -keys_foreach (GtkWindow *window, - guint keyval, - GdkModifierType modifiers, - gboolean is_mnemonic, - gpointer data) -{ - GHashTable *new_grabbed_keys = data; - GrabbedKey *key = g_slice_new (GrabbedKey); - - key->accelerator_key = keyval; - key->accelerator_mods = modifiers; - - g_hash_table_replace (new_grabbed_keys, key, key); -} - -static void -grabbed_key_free (gpointer data) -{ - g_slice_free (GrabbedKey, data); -} - -static void -gtk_plug_keys_changed (GtkWindow *window) -{ - GHashTable *new_grabbed_keys, *old_grabbed_keys; - GtkPlug *plug = GTK_PLUG (window); - GtkPlugPrivate *priv = plug->priv; - - new_grabbed_keys = g_hash_table_new_full (grabbed_key_hash, grabbed_key_equal, (GDestroyNotify)grabbed_key_free, NULL); - _gtk_window_keys_foreach (window, keys_foreach, new_grabbed_keys); - - if (priv->socket_window) - g_hash_table_foreach (new_grabbed_keys, add_grabbed_key, plug); - - old_grabbed_keys = priv->grabbed_keys; - priv->grabbed_keys = new_grabbed_keys; - - if (old_grabbed_keys) - { - if (priv->socket_window) - g_hash_table_foreach (old_grabbed_keys, remove_grabbed_key, plug); - g_hash_table_destroy (old_grabbed_keys); - } -} - -static void -gtk_plug_focus_to_parent (GtkPlug *plug, - GtkDirectionType direction) -{ - GtkPlugPrivate *priv = plug->priv; - XEmbedMessageType message; - - switch (direction) - { - case GTK_DIR_UP: - case GTK_DIR_LEFT: - case GTK_DIR_TAB_BACKWARD: - message = XEMBED_FOCUS_PREV; - break; - case GTK_DIR_DOWN: - case GTK_DIR_RIGHT: - case GTK_DIR_TAB_FORWARD: - message = XEMBED_FOCUS_NEXT; - break; - default: - g_assert_not_reached (); - message = XEMBED_FOCUS_PREV; - break; - } - - _gtk_xembed_send_focus_message (priv->socket_window, message, 0); -} - -static gboolean -gtk_plug_focus (GtkWidget *widget, - GtkDirectionType direction) -{ - GtkBin *bin = GTK_BIN (widget); - GtkPlug *plug = GTK_PLUG (widget); - GtkWindow *window = GTK_WINDOW (widget); - GtkContainer *container = GTK_CONTAINER (widget); - GtkWidget *child; - GtkWidget *old_focus_child; - GtkWidget *parent; - - old_focus_child = gtk_container_get_focus_child (container); - /* We override GtkWindow's behavior, since we don't want wrapping here. - */ - if (old_focus_child) - { - GtkWidget *focus_widget; - - if (gtk_widget_child_focus (old_focus_child, direction)) - return TRUE; - - focus_widget = gtk_window_get_focus (window); - if (focus_widget) - { - /* Wrapped off the end, clear the focus setting for the toplevel */ - parent = gtk_widget_get_parent (focus_widget); - while (parent) - { - gtk_container_set_focus_child (GTK_CONTAINER (parent), NULL); - parent = gtk_widget_get_parent (parent); - } - - gtk_window_set_focus (GTK_WINDOW (container), NULL); - } - } - else - { - /* Try to focus the first widget in the window */ - child = gtk_bin_get_child (bin); - if (child && gtk_widget_child_focus (child, direction)) - return TRUE; - } - - if (!gtk_container_get_focus_child (GTK_CONTAINER (window))) - gtk_plug_focus_to_parent (plug, direction); - - return FALSE; -} - -static void -gtk_plug_check_resize (GtkContainer *container) -{ - if (gtk_widget_is_toplevel (GTK_WIDGET (container))) - GTK_CONTAINER_CLASS (gtk_plug_parent_class)->check_resize (container); - else - GTK_CONTAINER_CLASS (bin_class)->check_resize (container); -} - diff --git a/gtk/gtkplug.h b/gtk/gtkplug.h deleted file mode 100644 index 1a2c1651ef..0000000000 --- a/gtk/gtkplug.h +++ /dev/null @@ -1,103 +0,0 @@ -/* GTK - The GIMP Toolkit - * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library. If not, see . - */ - -/* - * Modified by the GTK+ Team and others 1997-2000. See the AUTHORS - * file for a list of people on the GTK+ Team. See the ChangeLog - * files for a list of changes. These files are distributed with - * GTK+ at ftp://ftp.gtk.org/pub/gtk/. - */ - -#ifndef __GTK_PLUG_H__ -#define __GTK_PLUG_H__ - -#if !defined (__GTKX_H_INSIDE__) && !defined (GTK_COMPILATION) -#error "Only can be included directly." -#endif - -#include - -#ifdef GDK_WINDOWING_X11 - -#include - -#include -#include - -G_BEGIN_DECLS - -#define GTK_TYPE_PLUG (gtk_plug_get_type ()) -#define GTK_PLUG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_PLUG, GtkPlug)) -#define GTK_PLUG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_PLUG, GtkPlugClass)) -#define GTK_IS_PLUG(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_PLUG)) -#define GTK_IS_PLUG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_PLUG)) -#define GTK_PLUG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_PLUG, GtkPlugClass)) - - -typedef struct _GtkPlug GtkPlug; -typedef struct _GtkPlugPrivate GtkPlugPrivate; -typedef struct _GtkPlugClass GtkPlugClass; - - -struct _GtkPlug -{ - GtkWindow window; - - GtkPlugPrivate *priv; -}; - -struct _GtkPlugClass -{ - GtkWindowClass parent_class; - - void (*embedded) (GtkPlug *plug); - - /* Padding for future expansion */ - void (*_gtk_reserved1) (void); - void (*_gtk_reserved2) (void); - void (*_gtk_reserved3) (void); - void (*_gtk_reserved4) (void); -}; - -GDK_AVAILABLE_IN_ALL -GType gtk_plug_get_type (void) G_GNUC_CONST; - -GDK_AVAILABLE_IN_ALL -void gtk_plug_construct (GtkPlug *plug, - Window socket_id); -GDK_AVAILABLE_IN_ALL -GtkWidget *gtk_plug_new (Window socket_id); - -GDK_AVAILABLE_IN_ALL -void gtk_plug_construct_for_display (GtkPlug *plug, - GdkDisplay *display, - Window socket_id); -GDK_AVAILABLE_IN_ALL -GtkWidget *gtk_plug_new_for_display (GdkDisplay *display, - Window socket_id); -GDK_AVAILABLE_IN_ALL -Window gtk_plug_get_id (GtkPlug *plug); -GDK_AVAILABLE_IN_ALL -gboolean gtk_plug_get_embedded (GtkPlug *plug); -GDK_AVAILABLE_IN_ALL -GdkWindow *gtk_plug_get_socket_window (GtkPlug *plug); - -G_END_DECLS - -#endif /* GDK_WINDOWING_X11 */ - -#endif /* __GTK_PLUG_H__ */ diff --git a/gtk/gtksocket.c b/gtk/gtksocket.c deleted file mode 100644 index 1e19d0b3f7..0000000000 --- a/gtk/gtksocket.c +++ /dev/null @@ -1,1621 +0,0 @@ -/* GTK - The GIMP Toolkit - * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library. If not, see .Free - */ - -/* By Owen Taylor 98/4/4 */ - -/* - * Modified by the GTK+ Team and others 1997-2000. See the AUTHORS - * file for a list of people on the GTK+ Team. See the ChangeLog - * files for a list of changes. These files are distributed with - * GTK+ at ftp://ftp.gtk.org/pub/gtk/. - */ - -#include "config.h" - -#include "gtksocketprivate.h" - -#include - -#include "gtkmarshalers.h" -#include "gtksizerequest.h" -#include "gtkplug.h" -#include "gtkprivate.h" -#include "gtkrender.h" -#include "gtkdnd.h" -#include "gtkdragdest.h" -#include "gtkdebug.h" -#include "gtkintl.h" -#include "gtkmain.h" -#include "gtkwidgetprivate.h" - -#include -#include - -#ifdef HAVE_XFIXES -#include -#endif - -#include "gtkxembed.h" - - -/** - * SECTION:gtksocket - * @Short_description: Container for widgets from other processes - * @Title: GtkSocket - * @include: gtk/gtkx.h - * @See_also: #GtkPlug, [XEmbed Protocol](http://www.freedesktop.org/Standards/xembed-spec) - * - * Together with #GtkPlug, #GtkSocket provides the ability to embed - * widgets from one process into another process in a fashion that - * is transparent to the user. One process creates a #GtkSocket widget - * and passes that widget’s window ID to the other process, which then - * creates a #GtkPlug with that window ID. Any widgets contained in the - * #GtkPlug then will appear inside the first application’s window. - * - * The socket’s window ID is obtained by using gtk_socket_get_id(). - * Before using this function, the socket must have been realized, - * and for hence, have been added to its parent. - * - * ## Obtaining the window ID of a socket. - * - * |[ - * GtkWidget *socket = gtk_socket_new (); - * gtk_widget_show (socket); - * gtk_container_add (GTK_CONTAINER (parent), socket); - * - * // The following call is only necessary if one of - * // the ancestors of the socket is not yet visible. - * gtk_widget_realize (socket); - * g_print ("The ID of the sockets window is %#x\n", - * gtk_socket_get_id (socket)); - * ]| - * - * Note that if you pass the window ID of the socket to another - * process that will create a plug in the socket, you must make - * sure that the socket widget is not destroyed until that plug - * is created. Violating this rule will cause unpredictable - * consequences, the most likely consequence being that the plug - * will appear as a separate toplevel window. You can check if - * the plug has been created by using gtk_socket_get_plug_window(). - * If it returns a non-%NULL value, then the plug has been - * successfully created inside of the socket. - * - * When GTK+ is notified that the embedded window has been destroyed, - * then it will destroy the socket as well. You should always, - * therefore, be prepared for your sockets to be destroyed at any - * time when the main event loop is running. To prevent this from - * happening, you can connect to the #GtkSocket::plug-removed signal. - * - * The communication between a #GtkSocket and a #GtkPlug follows the - * [XEmbed Protocol](http://www.freedesktop.org/Standards/xembed-spec). - * This protocol has also been implemented in other toolkits, e.g. Qt, - * allowing the same level of integration when embedding a Qt widget - * in GTK or vice versa. - * - * The #GtkPlug and #GtkSocket widgets are only available when GTK+ - * is compiled for the X11 platform and %GDK_WINDOWING_X11 is defined. - * They can only be used on a #GdkX11Display. To use #GtkPlug and - * #GtkSocket, you need to include the `gtk/gtkx.h` header. - */ - -/* Forward declararations */ - -static void gtk_socket_finalize (GObject *object); -static void gtk_socket_notify (GObject *object, - GParamSpec *pspec); -static void gtk_socket_realize (GtkWidget *widget); -static void gtk_socket_unrealize (GtkWidget *widget); -static void gtk_socket_get_preferred_width (GtkWidget *widget, - gint *minimum, - gint *natural); -static void gtk_socket_get_preferred_height (GtkWidget *widget, - gint *minimum, - gint *natural); -static void gtk_socket_size_allocate (GtkWidget *widget, - GtkAllocation *allocation); -static void gtk_socket_hierarchy_changed (GtkWidget *widget, - GtkWidget *old_toplevel); -static void gtk_socket_grab_notify (GtkWidget *widget, - gboolean was_grabbed); -static gboolean gtk_socket_key_event (GtkWidget *widget, - GdkEventKey *event); -static gboolean gtk_socket_focus (GtkWidget *widget, - GtkDirectionType direction); -static void gtk_socket_remove (GtkContainer *container, - GtkWidget *widget); -static void gtk_socket_forall (GtkContainer *container, - gboolean include_internals, - GtkCallback callback, - gpointer callback_data); -static void gtk_socket_add_window (GtkSocket *socket, - Window xid, - gboolean need_reparent); -static GdkFilterReturn gtk_socket_filter_func (GdkXEvent *gdk_xevent, - GdkEvent *event, - gpointer data); - -static gboolean xembed_get_info (GdkWindow *gdk_window, - unsigned long *version, - unsigned long *flags); - -/* From Tk */ -#define EMBEDDED_APP_WANTS_FOCUS NotifyNormal+20 - - -/* Local data */ - -typedef struct -{ - guint accel_key; - GdkModifierType accel_mods; -} GrabbedKey; - -enum { - PLUG_ADDED, - PLUG_REMOVED, - LAST_SIGNAL -}; - -static guint socket_signals[LAST_SIGNAL] = { 0 }; - -G_DEFINE_TYPE_WITH_PRIVATE (GtkSocket, gtk_socket, GTK_TYPE_CONTAINER) - -static void -gtk_socket_finalize (GObject *object) -{ - GtkSocket *socket = GTK_SOCKET (object); - GtkSocketPrivate *priv = socket->priv; - - g_object_unref (priv->accel_group); - - G_OBJECT_CLASS (gtk_socket_parent_class)->finalize (object); -} - -static gboolean -gtk_socket_draw (GtkWidget *widget, - cairo_t *cr) -{ - gtk_render_background (gtk_widget_get_style_context (widget), cr, - 0, 0, - gtk_widget_get_allocated_width (widget), - gtk_widget_get_allocated_height (widget)); - - return GTK_WIDGET_CLASS (gtk_socket_parent_class)->draw (widget, cr); -} - -static void -gtk_socket_class_init (GtkSocketClass *class) -{ - GtkWidgetClass *widget_class; - GtkContainerClass *container_class; - GObjectClass *gobject_class; - - gobject_class = (GObjectClass *) class; - widget_class = (GtkWidgetClass*) class; - container_class = (GtkContainerClass*) class; - - gobject_class->finalize = gtk_socket_finalize; - gobject_class->notify = gtk_socket_notify; - - widget_class->realize = gtk_socket_realize; - widget_class->unrealize = gtk_socket_unrealize; - widget_class->get_preferred_width = gtk_socket_get_preferred_width; - widget_class->get_preferred_height = gtk_socket_get_preferred_height; - widget_class->size_allocate = gtk_socket_size_allocate; - widget_class->hierarchy_changed = gtk_socket_hierarchy_changed; - widget_class->grab_notify = gtk_socket_grab_notify; - widget_class->key_press_event = gtk_socket_key_event; - widget_class->key_release_event = gtk_socket_key_event; - widget_class->focus = gtk_socket_focus; - widget_class->draw = gtk_socket_draw; - - /* We don't want to show_all the in-process plug, if any. - */ - widget_class->show_all = gtk_widget_show; - - container_class->remove = gtk_socket_remove; - container_class->forall = gtk_socket_forall; - - /** - * GtkSocket::plug-added: - * @socket_: the object which received the signal - * - * This signal is emitted when a client is successfully - * added to the socket. - */ - socket_signals[PLUG_ADDED] = - g_signal_new (I_("plug-added"), - G_OBJECT_CLASS_TYPE (class), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (GtkSocketClass, plug_added), - NULL, NULL, - NULL, - G_TYPE_NONE, 0); - - /** - * GtkSocket::plug-removed: - * @socket_: the object which received the signal - * - * This signal is emitted when a client is removed from the socket. - * The default action is to destroy the #GtkSocket widget, so if you - * want to reuse it you must add a signal handler that returns %TRUE. - * - * Returns: %TRUE to stop other handlers from being invoked. - */ - socket_signals[PLUG_REMOVED] = - g_signal_new (I_("plug-removed"), - G_OBJECT_CLASS_TYPE (class), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (GtkSocketClass, plug_removed), - _gtk_boolean_handled_accumulator, NULL, - _gtk_marshal_BOOLEAN__VOID, - G_TYPE_BOOLEAN, 0); -} - -static void -gtk_socket_init (GtkSocket *socket) -{ - GtkSocketPrivate *priv; - - priv = gtk_socket_get_instance_private (socket); - socket->priv = priv; - - priv->request_width = 0; - priv->request_height = 0; - priv->current_width = 0; - priv->current_height = 0; - - priv->plug_window = NULL; - priv->plug_widget = NULL; - priv->focus_in = FALSE; - priv->have_size = FALSE; - priv->need_map = FALSE; - priv->active = FALSE; - - priv->accel_group = gtk_accel_group_new (); - g_object_set_data (G_OBJECT (priv->accel_group), I_("gtk-socket"), socket); -} - -/** - * gtk_socket_new: - * - * Create a new empty #GtkSocket. - * - * Returns: the new #GtkSocket. - **/ -GtkWidget* -gtk_socket_new (void) -{ - GtkSocket *socket; - - socket = g_object_new (GTK_TYPE_SOCKET, NULL); - - return GTK_WIDGET (socket); -} - -/** - * gtk_socket_add_id: - * @socket_: a #GtkSocket - * @window: the Window of a client participating in the XEMBED protocol. - * - * Adds an XEMBED client, such as a #GtkPlug, to the #GtkSocket. The - * client may be in the same process or in a different process. - * - * To embed a #GtkPlug in a #GtkSocket, you can either create the - * #GtkPlug with `gtk_plug_new (0)`, call - * gtk_plug_get_id() to get the window ID of the plug, and then pass that to the - * gtk_socket_add_id(), or you can call gtk_socket_get_id() to get the - * window ID for the socket, and call gtk_plug_new() passing in that - * ID. - * - * The #GtkSocket must have already be added into a toplevel window - * before you can make this call. - **/ -void -gtk_socket_add_id (GtkSocket *socket, - Window window) -{ - g_return_if_fail (GTK_IS_SOCKET (socket)); - g_return_if_fail (_gtk_widget_get_anchored (GTK_WIDGET (socket))); - - if (!gtk_widget_get_realized (GTK_WIDGET (socket))) - gtk_widget_realize (GTK_WIDGET (socket)); - - gtk_socket_add_window (socket, window, TRUE); -} - -/** - * gtk_socket_get_id: - * @socket_: a #GtkSocket. - * - * Gets the window ID of a #GtkSocket widget, which can then - * be used to create a client embedded inside the socket, for - * instance with gtk_plug_new(). - * - * The #GtkSocket must have already be added into a toplevel window - * before you can make this call. - * - * Returns: the window ID for the socket - **/ -Window -gtk_socket_get_id (GtkSocket *socket) -{ - g_return_val_if_fail (GTK_IS_SOCKET (socket), 0); - g_return_val_if_fail (_gtk_widget_get_anchored (GTK_WIDGET (socket)), 0); - - if (!gtk_widget_get_realized (GTK_WIDGET (socket))) - gtk_widget_realize (GTK_WIDGET (socket)); - - return GDK_WINDOW_XID (gtk_widget_get_window (GTK_WIDGET (socket))); -} - -/** - * gtk_socket_get_plug_window: - * @socket_: a #GtkSocket. - * - * Retrieves the window of the plug. Use this to check if the plug has - * been created inside of the socket. - * - * Returns: (nullable) (transfer none): the window of the plug if - * available, or %NULL - * - * Since: 2.14 - **/ -GdkWindow* -gtk_socket_get_plug_window (GtkSocket *socket) -{ - g_return_val_if_fail (GTK_IS_SOCKET (socket), NULL); - - return socket->priv->plug_window; -} - -static void -gtk_socket_realize (GtkWidget *widget) -{ - GtkAllocation allocation; - GdkWindow *window; - GdkWindowAttr attributes; - XWindowAttributes xattrs; - gint attributes_mask; - GdkScreen *screen; - - gtk_widget_set_realized (widget, TRUE); - - screen = gtk_widget_get_screen (widget); - if (!GDK_IS_X11_SCREEN (screen)) - g_warning ("GtkSocket: only works under X11"); - - gtk_widget_get_allocation (widget, &allocation); - - attributes.window_type = GDK_WINDOW_CHILD; - attributes.x = allocation.x; - attributes.y = allocation.y; - attributes.width = allocation.width; - attributes.height = allocation.height; - attributes.wclass = GDK_INPUT_OUTPUT; - attributes.visual = gtk_widget_get_visual (widget); - attributes.event_mask = GDK_FOCUS_CHANGE_MASK; - - attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL; - - window = gdk_window_new (gtk_widget_get_parent_window (widget), - &attributes, attributes_mask); - gtk_widget_set_window (widget, window); - gtk_widget_register_window (widget, window); - - XGetWindowAttributes (GDK_WINDOW_XDISPLAY (window), - GDK_WINDOW_XID (window), - &xattrs); - - /* Sooooo, it turns out that mozilla, as per the gtk2xt code selects - for input on the socket with a mask of 0x0fffff (for god knows why) - which includes ButtonPressMask causing a BadAccess if someone else - also selects for this. As per the client-side windows merge we always - normally selects for button press so we can emulate it on client - side children that selects for button press. However, we don't need - this for GtkSocket, so we unselect it here, fixing the crashes in - firefox. */ - XSelectInput (GDK_WINDOW_XDISPLAY (window), - GDK_WINDOW_XID (window), - (xattrs.your_event_mask & ~ButtonPressMask) | - SubstructureNotifyMask | SubstructureRedirectMask); - - gdk_window_add_filter (window, - gtk_socket_filter_func, - widget); - - /* We sync here so that we make sure that if the XID for - * our window is passed to another application, SubstructureRedirectMask - * will be set by the time the other app creates its window. - */ - gdk_display_sync (gtk_widget_get_display (widget)); -} - -/** - * gtk_socket_end_embedding: - * @socket: a #GtkSocket - * - * Called to end the embedding of a plug in the socket. - */ -static void -gtk_socket_end_embedding (GtkSocket *socket) -{ - GtkSocketPrivate *private = socket->priv; - - g_object_unref (private->plug_window); - private->plug_window = NULL; - private->current_width = 0; - private->current_height = 0; - private->resize_count = 0; - - gtk_accel_group_disconnect (private->accel_group, NULL); -} - -static void -gtk_socket_unrealize (GtkWidget *widget) -{ - GtkSocket *socket = GTK_SOCKET (widget); - GtkSocketPrivate *private = socket->priv; - - gtk_widget_set_realized (widget, FALSE); - - if (private->plug_widget) - { - _gtk_plug_remove_from_socket (GTK_PLUG (private->plug_widget), socket); - } - else if (private->plug_window) - { - gtk_socket_end_embedding (socket); - } - - GTK_WIDGET_CLASS (gtk_socket_parent_class)->unrealize (widget); -} - -static void -gtk_socket_size_request (GtkSocket *socket) -{ - GtkSocketPrivate *private = socket->priv; - XSizeHints hints; - long supplied; - - gdk_error_trap_push (); - - private->request_width = 1; - private->request_height = 1; - - if (XGetWMNormalHints (GDK_WINDOW_XDISPLAY (private->plug_window), - GDK_WINDOW_XID (private->plug_window), - &hints, &supplied)) - { - if (hints.flags & PMinSize) - { - private->request_width = MAX (hints.min_width, 1); - private->request_height = MAX (hints.min_height, 1); - } - else if (hints.flags & PBaseSize) - { - private->request_width = MAX (hints.base_width, 1); - private->request_height = MAX (hints.base_height, 1); - } - } - private->have_size = TRUE; - - gdk_error_trap_pop_ignored (); -} - -static void -gtk_socket_get_preferred_width (GtkWidget *widget, - gint *minimum, - gint *natural) -{ - GtkSocket *socket = GTK_SOCKET (widget); - GtkSocketPrivate *private = socket->priv; - - if (private->plug_widget) - { - gtk_widget_get_preferred_width (private->plug_widget, minimum, natural); - } - else - { - if (private->is_mapped && !private->have_size && private->plug_window) - gtk_socket_size_request (socket); - - if (private->is_mapped && private->have_size) - *minimum = *natural = MAX (private->request_width, 1); - else - *minimum = *natural = 1; - } -} - -static void -gtk_socket_get_preferred_height (GtkWidget *widget, - gint *minimum, - gint *natural) -{ - GtkSocket *socket = GTK_SOCKET (widget); - GtkSocketPrivate *private = socket->priv; - - if (private->plug_widget) - { - gtk_widget_get_preferred_height (private->plug_widget, minimum, natural); - } - else - { - if (private->is_mapped && !private->have_size && private->plug_window) - gtk_socket_size_request (socket); - - if (private->is_mapped && private->have_size) - *minimum = *natural = MAX (private->request_height, 1); - else - *minimum = *natural = 1; - } -} - -static void -gtk_socket_send_configure_event (GtkSocket *socket) -{ - GtkAllocation allocation; - XConfigureEvent xconfigure; - gint x, y; - - g_return_if_fail (socket->priv->plug_window != NULL); - - memset (&xconfigure, 0, sizeof (xconfigure)); - xconfigure.type = ConfigureNotify; - - xconfigure.event = GDK_WINDOW_XID (socket->priv->plug_window); - xconfigure.window = GDK_WINDOW_XID (socket->priv->plug_window); - - /* The ICCCM says that synthetic events should have root relative - * coordinates. We still aren't really ICCCM compliant, since - * we don't send events when the real toplevel is moved. - */ - gdk_error_trap_push (); - gdk_window_get_origin (socket->priv->plug_window, &x, &y); - gdk_error_trap_pop_ignored (); - - gtk_widget_get_allocation (GTK_WIDGET(socket), &allocation); - xconfigure.x = x; - xconfigure.y = y; - xconfigure.width = allocation.width; - xconfigure.height = allocation.height; - - xconfigure.border_width = 0; - xconfigure.above = None; - xconfigure.override_redirect = False; - - gdk_error_trap_push (); - XSendEvent (GDK_WINDOW_XDISPLAY (socket->priv->plug_window), - GDK_WINDOW_XID (socket->priv->plug_window), - False, NoEventMask, (XEvent *)&xconfigure); - gdk_error_trap_pop_ignored (); -} - -static void -gtk_socket_size_allocate (GtkWidget *widget, - GtkAllocation *allocation) -{ - GtkSocket *socket = GTK_SOCKET (widget); - GtkSocketPrivate *private = socket->priv; - - gtk_widget_set_allocation (widget, allocation); - if (gtk_widget_get_realized (widget)) - { - gdk_window_move_resize (gtk_widget_get_window (widget), - allocation->x, allocation->y, - allocation->width, allocation->height); - - if (private->plug_widget) - { - GtkAllocation child_allocation; - - child_allocation.x = 0; - child_allocation.y = 0; - child_allocation.width = allocation->width; - child_allocation.height = allocation->height; - - gtk_widget_size_allocate (private->plug_widget, &child_allocation); - } - else if (private->plug_window) - { - gdk_error_trap_push (); - - if (allocation->width != private->current_width || - allocation->height != private->current_height) - { - gdk_window_move_resize (private->plug_window, - 0, 0, - allocation->width, allocation->height); - if (private->resize_count) - private->resize_count--; - - GTK_NOTE (PLUGSOCKET, - g_message ("GtkSocket - allocated: %d %d", - allocation->width, allocation->height)); - private->current_width = allocation->width; - private->current_height = allocation->height; - } - - if (private->need_map) - { - gdk_window_show (private->plug_window); - private->need_map = FALSE; - } - - while (private->resize_count) - { - gtk_socket_send_configure_event (socket); - private->resize_count--; - GTK_NOTE (PLUGSOCKET, - g_message ("GtkSocket - sending synthetic configure: %d %d", - allocation->width, allocation->height)); - } - - gdk_error_trap_pop_ignored (); - } - } -} - -static void -gtk_socket_send_key_event (GtkSocket *socket, - GdkEvent *gdk_event, - gboolean mask_key_presses) -{ - XKeyEvent xkey; - GdkScreen *screen = gdk_window_get_screen (socket->priv->plug_window); - - memset (&xkey, 0, sizeof (xkey)); - xkey.type = (gdk_event->type == GDK_KEY_PRESS) ? KeyPress : KeyRelease; - xkey.window = GDK_WINDOW_XID (socket->priv->plug_window); - xkey.root = GDK_WINDOW_XID (gdk_screen_get_root_window (screen)); - xkey.subwindow = None; - xkey.time = gdk_event->key.time; - xkey.x = 0; - xkey.y = 0; - xkey.x_root = 0; - xkey.y_root = 0; - xkey.state = gdk_event->key.state; - xkey.keycode = gdk_event->key.hardware_keycode; - xkey.same_screen = True;/* FIXME ? */ - - gdk_error_trap_push (); - XSendEvent (GDK_WINDOW_XDISPLAY (socket->priv->plug_window), - GDK_WINDOW_XID (socket->priv->plug_window), - False, - (mask_key_presses ? KeyPressMask : NoEventMask), - (XEvent *)&xkey); - gdk_error_trap_pop_ignored (); -} - -static gboolean -activate_key (GtkAccelGroup *accel_group, - GObject *acceleratable, - guint accel_key, - GdkModifierType accel_mods, - GrabbedKey *grabbed_key) -{ - GdkEvent *gdk_event = gtk_get_current_event (); - - GtkSocket *socket = g_object_get_data (G_OBJECT (accel_group), "gtk-socket"); - gboolean retval = FALSE; - - if (gdk_event && gdk_event->type == GDK_KEY_PRESS && socket->priv->plug_window) - { - gtk_socket_send_key_event (socket, gdk_event, FALSE); - retval = TRUE; - } - - if (gdk_event) - gdk_event_free (gdk_event); - - return retval; -} - -static gboolean -find_accel_key (GtkAccelKey *key, - GClosure *closure, - gpointer data) -{ - GrabbedKey *grabbed_key = data; - - return (key->accel_key == grabbed_key->accel_key && - key->accel_mods == grabbed_key->accel_mods); -} - -/** - * gtk_socket_add_grabbed_key: - * @socket: a #GtkSocket - * @keyval: a key - * @modifiers: modifiers for the key - * - * Called from the GtkSocket platform-specific backend when the - * corresponding plug has told the socket to grab a key. - */ -static void -gtk_socket_add_grabbed_key (GtkSocket *socket, - guint keyval, - GdkModifierType modifiers) -{ - GClosure *closure; - GrabbedKey *grabbed_key; - - grabbed_key = g_new (GrabbedKey, 1); - - grabbed_key->accel_key = keyval; - grabbed_key->accel_mods = modifiers; - - if (gtk_accel_group_find (socket->priv->accel_group, - find_accel_key, - &grabbed_key)) - { - g_warning ("GtkSocket: request to add already present grabbed key %u,%#x", - keyval, modifiers); - g_free (grabbed_key); - return; - } - - closure = g_cclosure_new (G_CALLBACK (activate_key), grabbed_key, (GClosureNotify)g_free); - - gtk_accel_group_connect (socket->priv->accel_group, keyval, modifiers, GTK_ACCEL_LOCKED, - closure); -} - -/** - * gtk_socket_remove_grabbed_key: - * @socket: a #GtkSocket - * @keyval: a key - * @modifiers: modifiers for the key - * - * Called from the GtkSocket backend when the corresponding plug has - * told the socket to remove a key grab. - */ -static void -gtk_socket_remove_grabbed_key (GtkSocket *socket, - guint keyval, - GdkModifierType modifiers) -{ - if (!gtk_accel_group_disconnect_key (socket->priv->accel_group, keyval, modifiers)) - g_warning ("GtkSocket: request to remove non-present grabbed key %u,%#x", - keyval, modifiers); -} - -static void -socket_update_focus_in (GtkSocket *socket) -{ - GtkSocketPrivate *private = socket->priv; - gboolean focus_in = FALSE; - - if (private->plug_window) - { - GtkWidget *toplevel = gtk_widget_get_toplevel (GTK_WIDGET (socket)); - - if (gtk_widget_is_toplevel (toplevel) && - gtk_window_has_toplevel_focus (GTK_WINDOW (toplevel)) && - gtk_widget_is_focus (GTK_WIDGET (socket))) - focus_in = TRUE; - } - - if (focus_in != private->focus_in) - { - private->focus_in = focus_in; - - if (focus_in) - _gtk_xembed_send_focus_message (private->plug_window, - XEMBED_FOCUS_IN, XEMBED_FOCUS_CURRENT); - else - _gtk_xembed_send_message (private->plug_window, - XEMBED_FOCUS_OUT, 0, 0, 0); - } -} - -static void -socket_update_active (GtkSocket *socket) -{ - GtkSocketPrivate *private = socket->priv; - gboolean active = FALSE; - - if (private->plug_window) - { - GtkWidget *toplevel = gtk_widget_get_toplevel (GTK_WIDGET (socket)); - - if (gtk_widget_is_toplevel (toplevel) && - gtk_window_is_active (GTK_WINDOW (toplevel))) - active = TRUE; - } - - if (active != private->active) - { - private->active = active; - - _gtk_xembed_send_message (private->plug_window, - active ? XEMBED_WINDOW_ACTIVATE : XEMBED_WINDOW_DEACTIVATE, - 0, 0, 0); - } -} - -static void -gtk_socket_hierarchy_changed (GtkWidget *widget, - GtkWidget *old_toplevel) -{ - GtkSocket *socket = GTK_SOCKET (widget); - GtkSocketPrivate *private = socket->priv; - GtkWidget *toplevel = gtk_widget_get_toplevel (widget); - - if (toplevel && !GTK_IS_WINDOW (toplevel)) - toplevel = NULL; - - if (toplevel != private->toplevel) - { - if (private->toplevel) - { - gtk_window_remove_accel_group (GTK_WINDOW (private->toplevel), private->accel_group); - g_signal_handlers_disconnect_by_func (private->toplevel, - socket_update_focus_in, - socket); - g_signal_handlers_disconnect_by_func (private->toplevel, - socket_update_active, - socket); - } - - private->toplevel = toplevel; - - if (toplevel) - { - gtk_window_add_accel_group (GTK_WINDOW (private->toplevel), private->accel_group); - g_signal_connect_swapped (private->toplevel, "notify::has-toplevel-focus", - G_CALLBACK (socket_update_focus_in), socket); - g_signal_connect_swapped (private->toplevel, "notify::is-active", - G_CALLBACK (socket_update_active), socket); - } - - socket_update_focus_in (socket); - socket_update_active (socket); - } -} - -static void -gtk_socket_grab_notify (GtkWidget *widget, - gboolean was_grabbed) -{ - GtkSocket *socket = GTK_SOCKET (widget); - - if (!socket->priv->same_app) - _gtk_xembed_send_message (socket->priv->plug_window, - was_grabbed ? XEMBED_MODALITY_OFF : XEMBED_MODALITY_ON, - 0, 0, 0); -} - -static gboolean -gtk_socket_key_event (GtkWidget *widget, - GdkEventKey *event) -{ - GtkSocket *socket = GTK_SOCKET (widget); - GtkSocketPrivate *private = socket->priv; - - if (gtk_widget_has_focus (widget) && private->plug_window && !private->plug_widget) - { - gtk_socket_send_key_event (socket, (GdkEvent *) event, FALSE); - - return TRUE; - } - else - return FALSE; -} - -static void -gtk_socket_notify (GObject *object, - GParamSpec *pspec) -{ - if (strcmp (pspec->name, "is-focus") == 0) - socket_update_focus_in (GTK_SOCKET (object)); - - if (G_OBJECT_CLASS (gtk_socket_parent_class)->notify) - G_OBJECT_CLASS (gtk_socket_parent_class)->notify (object, pspec); -} - -/** - * gtk_socket_claim_focus: - * @socket: a #GtkSocket - * @send_event: huh? - * - * Claims focus for the socket. XXX send_event? - */ -static void -gtk_socket_claim_focus (GtkSocket *socket, - gboolean send_event) -{ - GtkWidget *widget = GTK_WIDGET (socket); - GtkSocketPrivate *private = socket->priv; - - if (!send_event) - private->focus_in = TRUE; /* Otherwise, our notify handler will send FOCUS_IN */ - - /* Oh, the trickery... */ - - gtk_widget_set_can_focus (widget, TRUE); - gtk_widget_grab_focus (widget); - gtk_widget_set_can_focus (widget, FALSE); -} - -static gboolean -gtk_socket_focus (GtkWidget *widget, - GtkDirectionType direction) -{ - GtkSocket *socket = GTK_SOCKET (widget); - GtkSocketPrivate *private = socket->priv; - - if (private->plug_widget) - return gtk_widget_child_focus (private->plug_widget, direction); - - if (!gtk_widget_is_focus (widget)) - { - gint detail = -1; - - switch (direction) - { - case GTK_DIR_UP: - case GTK_DIR_LEFT: - case GTK_DIR_TAB_BACKWARD: - detail = XEMBED_FOCUS_LAST; - break; - case GTK_DIR_DOWN: - case GTK_DIR_RIGHT: - case GTK_DIR_TAB_FORWARD: - detail = XEMBED_FOCUS_FIRST; - break; - } - - _gtk_xembed_send_focus_message (private->plug_window, XEMBED_FOCUS_IN, detail); - gtk_socket_claim_focus (socket, FALSE); - - return TRUE; - } - else - return FALSE; -} - -static void -gtk_socket_remove (GtkContainer *container, - GtkWidget *child) -{ - GtkSocket *socket = GTK_SOCKET (container); - GtkSocketPrivate *private = socket->priv; - - g_return_if_fail (child == private->plug_widget); - - _gtk_plug_remove_from_socket (GTK_PLUG (private->plug_widget), socket); -} - -static void -gtk_socket_forall (GtkContainer *container, - gboolean include_internals, - GtkCallback callback, - gpointer callback_data) -{ - GtkSocket *socket = GTK_SOCKET (container); - GtkSocketPrivate *private = socket->priv; - - if (private->plug_widget) - (* callback) (private->plug_widget, callback_data); -} - -/** - * gtk_socket_add_window: - * @socket: a #GtkSocket - * @xid: the native identifier for a window - * @need_reparent: whether the socket’s plug’s window needs to be - * reparented to the socket - * - * Adds a window to a GtkSocket. - */ -static void -gtk_socket_add_window (GtkSocket *socket, - Window xid, - gboolean need_reparent) -{ - GtkWidget *widget = GTK_WIDGET (socket); - GdkDisplay *display = gtk_widget_get_display (widget); - gpointer user_data = NULL; - GtkSocketPrivate *private = socket->priv; - unsigned long version; - unsigned long flags; - - if (GDK_IS_X11_DISPLAY (display)) - private->plug_window = gdk_x11_window_lookup_for_display (display, xid); - else - private->plug_window = NULL; - - if (private->plug_window) - { - g_object_ref (private->plug_window); - gdk_window_get_user_data (private->plug_window, &user_data); - } - - if (user_data) /* A widget's window in this process */ - { - GtkWidget *child_widget = user_data; - - if (!GTK_IS_PLUG (child_widget)) - { - g_warning (G_STRLOC ": Can't add non-GtkPlug to GtkSocket"); - private->plug_window = NULL; - gdk_error_trap_pop_ignored (); - - return; - } - - _gtk_plug_add_to_socket (GTK_PLUG (child_widget), socket); - } - else /* A foreign window */ - { - GdkDragProtocol protocol; - - gdk_error_trap_push (); - - if (!private->plug_window) - { - if (GDK_IS_X11_DISPLAY (display)) - private->plug_window = gdk_x11_window_foreign_new_for_display (display, xid); - if (!private->plug_window) /* was deleted before we could get it */ - { - gdk_error_trap_pop_ignored (); - return; - } - } - - XSelectInput (GDK_DISPLAY_XDISPLAY (gtk_widget_get_display (GTK_WIDGET (socket))), - GDK_WINDOW_XID (private->plug_window), - StructureNotifyMask | PropertyChangeMask); - - if (gdk_error_trap_pop ()) - { - g_object_unref (private->plug_window); - private->plug_window = NULL; - return; - } - - /* OK, we now will reliably get destroy notification on socket->plug_window */ - - gdk_error_trap_push (); - - if (need_reparent) - { - gdk_window_hide (private->plug_window); /* Shouldn't actually be necessary for XEMBED, but just in case */ - gdk_window_reparent (private->plug_window, - gtk_widget_get_window (widget), - 0, 0); - } - - private->have_size = FALSE; - - private->xembed_version = -1; - if (xembed_get_info (private->plug_window, &version, &flags)) - { - private->xembed_version = MIN (GTK_XEMBED_PROTOCOL_VERSION, version); - private->is_mapped = (flags & XEMBED_MAPPED) != 0; - } - else - { - /* FIXME, we should probably actually check the state before we started */ - private->is_mapped = TRUE; - } - - private->need_map = private->is_mapped; - - protocol = gdk_window_get_drag_protocol (private->plug_window, NULL); - if (protocol) - gtk_drag_dest_set_proxy (GTK_WIDGET (socket), private->plug_window, - protocol, TRUE); - - gdk_error_trap_pop_ignored (); - - gdk_window_add_filter (private->plug_window, - gtk_socket_filter_func, - socket); - -#ifdef HAVE_XFIXES - gdk_error_trap_push (); - XFixesChangeSaveSet (GDK_DISPLAY_XDISPLAY (gtk_widget_get_display (GTK_WIDGET (socket))), - GDK_WINDOW_XID (private->plug_window), - SetModeInsert, SaveSetRoot, SaveSetUnmap); - gdk_error_trap_pop_ignored (); -#endif - _gtk_xembed_send_message (private->plug_window, - XEMBED_EMBEDDED_NOTIFY, 0, - GDK_WINDOW_XID (gtk_widget_get_window (GTK_WIDGET (socket))), - private->xembed_version); - - socket_update_active (socket); - socket_update_focus_in (socket); - - gtk_widget_queue_resize (GTK_WIDGET (socket)); - } - - if (private->plug_window) - g_signal_emit (socket, socket_signals[PLUG_ADDED], 0); -} - -/** - * gtk_socket_handle_map_request: - * @socket: a #GtkSocket - * - * Called from the GtkSocket backend when the plug has been mapped. - */ -static void -gtk_socket_handle_map_request (GtkSocket *socket) -{ - GtkSocketPrivate *private = socket->priv; - if (!private->is_mapped) - { - private->is_mapped = TRUE; - private->need_map = TRUE; - - gtk_widget_queue_resize (GTK_WIDGET (socket)); - } -} - -/** - * gtk_socket_unmap_notify: - * @socket: a #GtkSocket - * - * Called from the GtkSocket backend when the plug has been unmapped ??? - */ -static void -gtk_socket_unmap_notify (GtkSocket *socket) -{ - GtkSocketPrivate *private = socket->priv; - if (private->is_mapped) - { - private->is_mapped = FALSE; - gtk_widget_queue_resize (GTK_WIDGET (socket)); - } -} - -/** - * gtk_socket_advance_toplevel_focus: - * @socket: a #GtkSocket - * @direction: a direction - * - * Called from the GtkSocket backend when the corresponding plug - * has told the socket to move the focus. - */ -static void -gtk_socket_advance_toplevel_focus (GtkSocket *socket, - GtkDirectionType direction) -{ - GtkBin *bin; - GtkWindow *window; - GtkContainer *container; - GtkWidget *child; - GtkWidget *focus_widget; - GtkWidget *toplevel; - GtkWidget *old_focus_child; - GtkWidget *parent; - - toplevel = gtk_widget_get_toplevel (GTK_WIDGET (socket)); - if (!toplevel) - return; - - if (!gtk_widget_is_toplevel (toplevel) || GTK_IS_PLUG (toplevel)) - { - gtk_widget_child_focus (toplevel,direction); - return; - } - - container = GTK_CONTAINER (toplevel); - window = GTK_WINDOW (toplevel); - bin = GTK_BIN (toplevel); - - /* This is a copy of gtk_window_focus(), modified so that we - * can detect wrap-around. - */ - old_focus_child = gtk_container_get_focus_child (container); - - if (old_focus_child) - { - if (gtk_widget_child_focus (old_focus_child, direction)) - return; - - /* We are allowed exactly one wrap-around per sequence of focus - * events - */ - if (_gtk_xembed_get_focus_wrapped ()) - return; - else - _gtk_xembed_set_focus_wrapped (); - } - - focus_widget = gtk_window_get_focus (window); - if (window) - { - /* Wrapped off the end, clear the focus setting for the toplevel */ - parent = gtk_widget_get_parent (focus_widget); - while (parent) - { - gtk_container_set_focus_child (GTK_CONTAINER (parent), NULL); - parent = gtk_widget_get_parent (parent); - } - - gtk_window_set_focus (GTK_WINDOW (container), NULL); - } - - /* Now try to focus the first widget in the window */ - child = gtk_bin_get_child (bin); - if (child) - { - if (gtk_widget_child_focus (child, direction)) - return; - } -} - -static gboolean -xembed_get_info (GdkWindow *window, - unsigned long *version, - unsigned long *flags) -{ - GdkDisplay *display = gdk_window_get_display (window); - Atom xembed_info_atom = gdk_x11_get_xatom_by_name_for_display (display, "_XEMBED_INFO"); - Atom type; - int format; - unsigned long nitems, bytes_after; - unsigned char *data; - unsigned long *data_long; - int status; - - gdk_error_trap_push (); - status = XGetWindowProperty (GDK_DISPLAY_XDISPLAY (display), - GDK_WINDOW_XID (window), - xembed_info_atom, - 0, 2, False, - xembed_info_atom, &type, &format, - &nitems, &bytes_after, &data); - gdk_error_trap_pop_ignored (); - - if (status != Success) - return FALSE; /* Window vanished? */ - - if (type == None) /* No info property */ - return FALSE; - - if (type != xembed_info_atom) - { - g_warning ("_XEMBED_INFO property has wrong type"); - return FALSE; - } - - if (nitems < 2) - { - g_warning ("_XEMBED_INFO too short"); - XFree (data); - return FALSE; - } - - data_long = (unsigned long *)data; - if (version) - *version = data_long[0]; - if (flags) - *flags = data_long[1] & XEMBED_MAPPED; - - XFree (data); - return TRUE; -} - -static void -handle_xembed_message (GtkSocket *socket, - XEmbedMessageType message, - glong detail, - glong data1, - glong data2, - guint32 time) -{ - GTK_NOTE (PLUGSOCKET, - g_message ("GtkSocket: %s received", _gtk_xembed_message_name (message))); - - switch (message) - { - case XEMBED_EMBEDDED_NOTIFY: - case XEMBED_WINDOW_ACTIVATE: - case XEMBED_WINDOW_DEACTIVATE: - case XEMBED_MODALITY_ON: - case XEMBED_MODALITY_OFF: - case XEMBED_FOCUS_IN: - case XEMBED_FOCUS_OUT: - g_warning ("GtkSocket: Invalid _XEMBED message %s received", _gtk_xembed_message_name (message)); - break; - - case XEMBED_REQUEST_FOCUS: - gtk_socket_claim_focus (socket, TRUE); - break; - - case XEMBED_FOCUS_NEXT: - case XEMBED_FOCUS_PREV: - gtk_socket_advance_toplevel_focus (socket, - (message == XEMBED_FOCUS_NEXT ? - GTK_DIR_TAB_FORWARD : GTK_DIR_TAB_BACKWARD)); - break; - - case XEMBED_GTK_GRAB_KEY: - gtk_socket_add_grabbed_key (socket, data1, data2); - break; - case XEMBED_GTK_UNGRAB_KEY: - gtk_socket_remove_grabbed_key (socket, data1, data2); - break; - - case XEMBED_GRAB_KEY: - case XEMBED_UNGRAB_KEY: - break; - - default: - GTK_NOTE (PLUGSOCKET, - g_message ("GtkSocket: Ignoring unknown _XEMBED message of type %d", message)); - break; - } -} - -static GdkFilterReturn -gtk_socket_filter_func (GdkXEvent *gdk_xevent, - GdkEvent *event, - gpointer data) -{ - GtkSocket *socket; - GtkWidget *widget; - GdkDisplay *display; - XEvent *xevent; - GtkSocketPrivate *private; - - GdkFilterReturn return_val; - - socket = GTK_SOCKET (data); - private = socket->priv; - - return_val = GDK_FILTER_CONTINUE; - - if (private->plug_widget) - return return_val; - - widget = GTK_WIDGET (socket); - xevent = (XEvent *)gdk_xevent; - display = gtk_widget_get_display (widget); - - switch (xevent->type) - { - case ClientMessage: - if (xevent->xclient.message_type == gdk_x11_get_xatom_by_name_for_display (display, "_XEMBED")) - { - _gtk_xembed_push_message (xevent); - handle_xembed_message (socket, - xevent->xclient.data.l[1], - xevent->xclient.data.l[2], - xevent->xclient.data.l[3], - xevent->xclient.data.l[4], - xevent->xclient.data.l[0]); - _gtk_xembed_pop_message (); - - return_val = GDK_FILTER_REMOVE; - } - break; - - case CreateNotify: - { - XCreateWindowEvent *xcwe = &xevent->xcreatewindow; - - if (!private->plug_window) - { - gtk_socket_add_window (socket, xcwe->window, FALSE); - - if (private->plug_window) - { - GTK_NOTE (PLUGSOCKET, g_message ("GtkSocket - window created")); - } - } - - return_val = GDK_FILTER_REMOVE; - - break; - } - - case ConfigureRequest: - { - XConfigureRequestEvent *xcre = &xevent->xconfigurerequest; - - if (!private->plug_window) - gtk_socket_add_window (socket, xcre->window, FALSE); - - if (private->plug_window) - { - if (xcre->value_mask & (CWWidth | CWHeight)) - { - GTK_NOTE (PLUGSOCKET, - g_message ("GtkSocket - configure request: %d %d", - private->request_width, - private->request_height)); - - private->resize_count++; - gtk_widget_queue_resize (widget); - } - else if (xcre->value_mask & (CWX | CWY)) - { - gtk_socket_send_configure_event (socket); - } - /* Ignore stacking requests. */ - - return_val = GDK_FILTER_REMOVE; - } - break; - } - - case DestroyNotify: - { - XDestroyWindowEvent *xdwe = &xevent->xdestroywindow; - - /* Note that we get destroy notifies both from SubstructureNotify on - * our window and StructureNotify on socket->plug_window - */ - if (private->plug_window && (xdwe->window == GDK_WINDOW_XID (private->plug_window))) - { - gboolean result; - - GTK_NOTE (PLUGSOCKET, g_message ("GtkSocket - destroy notify")); - - gdk_window_destroy_notify (private->plug_window); - gtk_socket_end_embedding (socket); - - g_object_ref (widget); - g_signal_emit_by_name (widget, "plug-removed", &result); - if (!result) - gtk_widget_destroy (widget); - g_object_unref (widget); - - return_val = GDK_FILTER_REMOVE; - } - break; - } - - case FocusIn: - if (xevent->xfocus.mode == EMBEDDED_APP_WANTS_FOCUS) - { - gtk_socket_claim_focus (socket, TRUE); - } - return_val = GDK_FILTER_REMOVE; - break; - case FocusOut: - return_val = GDK_FILTER_REMOVE; - break; - case MapRequest: - if (!private->plug_window) - { - gtk_socket_add_window (socket, xevent->xmaprequest.window, FALSE); - } - - if (private->plug_window) - { - GTK_NOTE (PLUGSOCKET, g_message ("GtkSocket - Map Request")); - - gtk_socket_handle_map_request (socket); - return_val = GDK_FILTER_REMOVE; - } - break; - case PropertyNotify: - if (private->plug_window && - xevent->xproperty.window == GDK_WINDOW_XID (private->plug_window)) - { - GdkDragProtocol protocol; - - if (xevent->xproperty.atom == gdk_x11_get_xatom_by_name_for_display (display, "WM_NORMAL_HINTS")) - { - GTK_NOTE (PLUGSOCKET, g_message ("GtkSocket - received PropertyNotify for plug's WM_NORMAL_HINTS")); - private->have_size = FALSE; - gtk_widget_queue_resize (widget); - return_val = GDK_FILTER_REMOVE; - } - else if ((xevent->xproperty.atom == gdk_x11_get_xatom_by_name_for_display (display, "XdndAware")) || - (xevent->xproperty.atom == gdk_x11_get_xatom_by_name_for_display (display, "_MOTIF_DRAG_RECEIVER_INFO"))) - { - gdk_error_trap_push (); - protocol = gdk_window_get_drag_protocol (private->plug_window, NULL); - if (protocol) - gtk_drag_dest_set_proxy (GTK_WIDGET (socket), - private->plug_window, - protocol, TRUE); - - gdk_error_trap_pop_ignored (); - return_val = GDK_FILTER_REMOVE; - } - else if (xevent->xproperty.atom == gdk_x11_get_xatom_by_name_for_display (display, "_XEMBED_INFO")) - { - unsigned long flags; - - if (xembed_get_info (private->plug_window, NULL, &flags)) - { - gboolean was_mapped = private->is_mapped; - gboolean is_mapped = (flags & XEMBED_MAPPED) != 0; - - if (was_mapped != is_mapped) - { - if (is_mapped) - gtk_socket_handle_map_request (socket); - else - { - gdk_error_trap_push (); - gdk_window_show (private->plug_window); - gdk_error_trap_pop_ignored (); - - gtk_socket_unmap_notify (socket); - } - } - } - return_val = GDK_FILTER_REMOVE; - } - } - break; - case ReparentNotify: - { - GdkWindow *window; - XReparentEvent *xre = &xevent->xreparent; - - window = gtk_widget_get_window (widget); - - GTK_NOTE (PLUGSOCKET, g_message ("GtkSocket - ReparentNotify received")); - if (!private->plug_window && - xre->parent == GDK_WINDOW_XID (window)) - { - gtk_socket_add_window (socket, xre->window, FALSE); - - if (private->plug_window) - { - GTK_NOTE (PLUGSOCKET, g_message ("GtkSocket - window reparented")); - } - - return_val = GDK_FILTER_REMOVE; - } - else - { - if (private->plug_window && - xre->window == GDK_WINDOW_XID (private->plug_window) && - xre->parent != GDK_WINDOW_XID (window)) - { - gboolean result; - - gtk_socket_end_embedding (socket); - - g_object_ref (widget); - g_signal_emit_by_name (widget, "plug-removed", &result); - if (!result) - gtk_widget_destroy (widget); - g_object_unref (widget); - - return_val = GDK_FILTER_REMOVE; - } - } - - break; - } - case UnmapNotify: - if (private->plug_window && - xevent->xunmap.window == GDK_WINDOW_XID (private->plug_window)) - { - GTK_NOTE (PLUGSOCKET, g_message ("GtkSocket - Unmap notify")); - - gtk_socket_unmap_notify (socket); - return_val = GDK_FILTER_REMOVE; - } - break; - - } - - return return_val; -} diff --git a/gtk/gtksocket.h b/gtk/gtksocket.h deleted file mode 100644 index ec22ba1337..0000000000 --- a/gtk/gtksocket.h +++ /dev/null @@ -1,89 +0,0 @@ -/* GTK - The GIMP Toolkit - * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library. If not, see . - */ - -/* - * Modified by the GTK+ Team and others 1997-2000. See the AUTHORS - * file for a list of people on the GTK+ Team. See the ChangeLog - * files for a list of changes. These files are distributed with - * GTK+ at ftp://ftp.gtk.org/pub/gtk/. - */ - -#ifndef __GTK_SOCKET_H__ -#define __GTK_SOCKET_H__ - -#if !defined (__GTKX_H_INSIDE__) && !defined (GTK_COMPILATION) -#error "Only can be included directly." -#endif - -#ifdef GDK_WINDOWING_X11 - -#include - -#include - -G_BEGIN_DECLS - -#define GTK_TYPE_SOCKET (gtk_socket_get_type ()) -#define GTK_SOCKET(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_SOCKET, GtkSocket)) -#define GTK_SOCKET_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_SOCKET, GtkSocketClass)) -#define GTK_IS_SOCKET(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_SOCKET)) -#define GTK_IS_SOCKET_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_SOCKET)) -#define GTK_SOCKET_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_SOCKET, GtkSocketClass)) - - -typedef struct _GtkSocket GtkSocket; -typedef struct _GtkSocketClass GtkSocketClass; -typedef struct _GtkSocketPrivate GtkSocketPrivate; - -struct _GtkSocket -{ - GtkContainer container; - - GtkSocketPrivate *priv; -}; - -struct _GtkSocketClass -{ - GtkContainerClass parent_class; - - void (*plug_added) (GtkSocket *socket_); - gboolean (*plug_removed) (GtkSocket *socket_); - - /* Padding for future expansion */ - void (*_gtk_reserved1) (void); - void (*_gtk_reserved2) (void); - void (*_gtk_reserved3) (void); - void (*_gtk_reserved4) (void); -}; - -GDK_AVAILABLE_IN_ALL -GType gtk_socket_get_type (void) G_GNUC_CONST; -GDK_AVAILABLE_IN_ALL -GtkWidget *gtk_socket_new (void); -GDK_AVAILABLE_IN_ALL -void gtk_socket_add_id (GtkSocket *socket_, - Window window); -GDK_AVAILABLE_IN_ALL -Window gtk_socket_get_id (GtkSocket *socket_); -GDK_AVAILABLE_IN_ALL -GdkWindow *gtk_socket_get_plug_window (GtkSocket *socket_); - -G_END_DECLS - -#endif /* GDK_WINDOWING_X11 */ - -#endif /* __GTK_SOCKET_H__ */ diff --git a/gtk/gtksocketprivate.h b/gtk/gtksocketprivate.h deleted file mode 100644 index 4f9d4f8be2..0000000000 --- a/gtk/gtksocketprivate.h +++ /dev/null @@ -1,61 +0,0 @@ -/* GTK - The GIMP Toolkit - * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library. If not, see . - */ - -/* - * Modified by the GTK+ Team and others 1997-2000. See the AUTHORS - * file for a list of people on the GTK+ Team. See the ChangeLog - * files for a list of changes. These files are distributed with - * GTK+ at ftp://ftp.gtk.org/pub/gtk/. - */ - -#ifndef __GTK_SOCKET_PRIVATE_H__ -#define __GTK_SOCKET_PRIVATE_H__ - -#include "gtkplug.h" -#include "gtksocket.h" - -struct _GtkSocketPrivate -{ - gint resize_count; - - guint16 request_width; - guint16 request_height; - guint16 current_width; - guint16 current_height; - - GdkWindow *plug_window; - GtkWidget *plug_widget; - - gshort xembed_version; /* -1 == not xembed */ - guint same_app : 1; - guint focus_in : 1; - guint have_size : 1; - guint need_map : 1; - guint is_mapped : 1; - guint active : 1; - - GtkAccelGroup *accel_group; - GtkWidget *toplevel; -}; - -/* from gtkplug.c */ -void _gtk_plug_add_to_socket (GtkPlug *plug, - GtkSocket *socket_); -void _gtk_plug_remove_from_socket (GtkPlug *plug, - GtkSocket *socket_); - -#endif /* __GTK_SOCKET_PRIVATE_H__ */ diff --git a/gtk/gtktestutils.c b/gtk/gtktestutils.c index 7b78f739fe..d0fe541ff3 100644 --- a/gtk/gtktestutils.c +++ b/gtk/gtktestutils.c @@ -37,7 +37,7 @@ * So.... */ #undef GTK_COMPILATION -#include +#include #define GTK_COMPILATION /** diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c index f46114605c..932bea4484 100644 --- a/gtk/gtkwidget.c +++ b/gtk/gtkwidget.c @@ -63,7 +63,6 @@ #include "gtkmodifierstyle.h" #include "gtkversion.h" #include "gtkdebug.h" -#include "gtkplug.h" #include "gtktypebuiltins.h" #include "a11y/gtkwidgetaccessible.h" #include "gtkapplicationprivate.h" @@ -9120,9 +9119,8 @@ gtk_widget_get_has_window (GtkWidget *widget) * * Determines whether @widget is a toplevel widget. * - * Currently only #GtkWindow and #GtkInvisible (and out-of-process - * #GtkPlugs) are toplevel widgets. Toplevel widgets have no parent - * widget. + * Currently only #GtkWindow and #GtkInvisible are toplevel widgets. + * Toplevel widgets have no parent widget. * * Returns: %TRUE if @widget is a toplevel, %FALSE otherwise * @@ -10617,8 +10615,6 @@ gtk_widget_set_parent_window (GtkWidget *widget, if (parent_window != old_parent_window) { - gboolean is_plug; - g_object_set_qdata (G_OBJECT (widget), quark_parent_window, parent_window); if (old_parent_window) @@ -10630,12 +10626,7 @@ gtk_widget_set_parent_window (GtkWidget *widget, * this is the primary entry point to allow toplevels to be * embeddable. */ -#ifdef GDK_WINDOWING_X11 - is_plug = GTK_IS_PLUG (widget); -#else - is_plug = FALSE; -#endif - if (GTK_IS_WINDOW (widget) && !is_plug) + if (GTK_IS_WINDOW (widget)) _gtk_window_set_is_toplevel (GTK_WINDOW (widget), parent_window == NULL); } } @@ -11462,9 +11453,7 @@ gtk_widget_add_device_events (GtkWidget *widget, * would return * %NULL if @widget wasn’t inside a toplevel window, and if the * window was inside a #GtkWindow-derived widget which was in turn - * inside the toplevel #GtkWindow. While the second case may - * seem unlikely, it actually happens when a #GtkPlug is embedded - * inside a #GtkSocket within the same application. + * inside the toplevel #GtkWindow. * * To reliably find the toplevel #GtkWindow, use * gtk_widget_get_toplevel() and call gtk_widget_is_toplevel() diff --git a/gtk/gtkwin32embed.c b/gtk/gtkwin32embed.c deleted file mode 100644 index b40185b220..0000000000 --- a/gtk/gtkwin32embed.c +++ /dev/null @@ -1,131 +0,0 @@ -/* GTK - The GIMP Toolkit - * gtkwin32embed.c: Utilities for Win32 embedding - * Copyright (C) 2005, Novell, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library. If not, see . - */ - -/* By Tor Lillqvist 2005 */ - -#include "config.h" - -#include "win32/gdkwin32.h" - -#include "gtkwin32embed.h" - - -static guint message_type[GTK_WIN32_EMBED_LAST]; - -static GSList *current_messages; - -guint -_gtk_win32_embed_message_type (GtkWin32EmbedMessageType type) -{ - if (type < 0 || type >= GTK_WIN32_EMBED_LAST) - return 0; - - if (message_type[type] == 0) - { - char name[100]; - sprintf (name, "gtk-win32-embed:%d", type); - message_type[type] = RegisterWindowMessage (name); - } - - return message_type[type]; -} - -void -_gtk_win32_embed_push_message (MSG *msg) -{ - MSG *message = g_new (MSG, 1); - - *message = *msg; - - current_messages = g_slist_prepend (current_messages, message); -} - -void -_gtk_win32_embed_pop_message (void) -{ - MSG *message = current_messages->data; - - current_messages = g_slist_delete_link (current_messages, current_messages); - - g_free (message); -} - -void -_gtk_win32_embed_send (GdkWindow *recipient, - GtkWin32EmbedMessageType message, - WPARAM wparam, - LPARAM lparam) -{ - PostMessage (GDK_WINDOW_HWND (recipient), - _gtk_win32_embed_message_type (message), - wparam, lparam); -} - -void -_gtk_win32_embed_send_focus_message (GdkWindow *recipient, - GtkWin32EmbedMessageType message, - WPARAM wparam) -{ - int lparam = 0; - - if (!recipient) - return; - - g_return_if_fail (GDK_IS_WINDOW (recipient)); - g_return_if_fail (message == GTK_WIN32_EMBED_FOCUS_IN || - message == GTK_WIN32_EMBED_FOCUS_NEXT || - message == GTK_WIN32_EMBED_FOCUS_PREV); - - if (current_messages) - { - MSG *msg = current_messages->data; - if (msg->message == _gtk_win32_embed_message_type (GTK_WIN32_EMBED_FOCUS_IN) || - msg->message == _gtk_win32_embed_message_type (GTK_WIN32_EMBED_FOCUS_NEXT) || - msg->message == _gtk_win32_embed_message_type (GTK_WIN32_EMBED_FOCUS_PREV)) - lparam = (msg->lParam & GTK_WIN32_EMBED_FOCUS_WRAPAROUND); - } - - _gtk_win32_embed_send (recipient, message, wparam, lparam); -} - -void -_gtk_win32_embed_set_focus_wrapped (void) -{ - MSG *msg; - - g_return_if_fail (current_messages != NULL); - - msg = current_messages->data; - - g_return_if_fail (msg->message == _gtk_win32_embed_message_type (GTK_WIN32_EMBED_FOCUS_PREV) || - msg->message == _gtk_win32_embed_message_type (GTK_WIN32_EMBED_FOCUS_NEXT)); - - msg->lParam |= GTK_WIN32_EMBED_FOCUS_WRAPAROUND; -} - -gboolean -_gtk_win32_embed_get_focus_wrapped (void) -{ - MSG *msg; - - g_return_val_if_fail (current_messages != NULL, FALSE); - - msg = current_messages->data; - - return (msg->lParam & GTK_WIN32_EMBED_FOCUS_WRAPAROUND) != 0; -} diff --git a/gtk/gtkwin32embed.h b/gtk/gtkwin32embed.h deleted file mode 100644 index da08dfd875..0000000000 --- a/gtk/gtkwin32embed.h +++ /dev/null @@ -1,93 +0,0 @@ -/* GTK - The GIMP Toolkit - * gtkwin32embed.h: Utilities for Win32 embedding - * Copyright (C) 2005, Novell, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library. If not, see . - */ - -/* By Tor Lillqvist 2005 */ - -#ifndef __GTK_WIN32_EMBED_H__ -#define __GTK_WIN32_EMBED_H__ - -G_BEGIN_DECLS - -#define GTK_WIN32_EMBED_PROTOCOL_VERSION 1 - -/* - * When the plug and socket are in separate processes they use a - * simple protocol, more or less based on XEMBED. The protocol uses - * registered window messages. The name passed to - * RegisterWindowMessage() is gtk-win32-embed:%d, with %d being the - * numeric value of an GtkWin32EmbedMessageType enum. Each message - * carries the message type enum value and two integers, the “wparam” - * and “lparam”, like all window messages. - * - * So far all the window messages are posted to the other - * process. Maybe some later enhancement will add also messages that - * are sent, i.e. where the sending process waits for the receiving - * process’s window procedure to handle the message. - */ - -typedef enum { /* send or post? */ - /* First those sent from the socket - * to the plug - */ - GTK_WIN32_EMBED_WINDOW_ACTIVATE, /* post */ - GTK_WIN32_EMBED_WINDOW_DEACTIVATE, /* post */ - GTK_WIN32_EMBED_FOCUS_IN, /* post */ - GTK_WIN32_EMBED_FOCUS_OUT, /* post */ - GTK_WIN32_EMBED_MODALITY_ON, /* post */ - GTK_WIN32_EMBED_MODALITY_OFF, /* post */ - - /* Then the ones sent from the plug - * to the socket. - */ - GTK_WIN32_EMBED_PARENT_NOTIFY, /* post */ - GTK_WIN32_EMBED_EVENT_PLUG_MAPPED, /* post */ - GTK_WIN32_EMBED_PLUG_RESIZED, /* post */ - GTK_WIN32_EMBED_REQUEST_FOCUS, /* post */ - GTK_WIN32_EMBED_FOCUS_NEXT, /* post */ - GTK_WIN32_EMBED_FOCUS_PREV, /* post */ - GTK_WIN32_EMBED_GRAB_KEY, /* post */ - GTK_WIN32_EMBED_UNGRAB_KEY, /* post */ - GTK_WIN32_EMBED_LAST -} GtkWin32EmbedMessageType; - -/* wParam values for GTK_WIN32_EMBED_FOCUS_IN: */ -#define GTK_WIN32_EMBED_FOCUS_CURRENT 0 -#define GTK_WIN32_EMBED_FOCUS_FIRST 1 -#define GTK_WIN32_EMBED_FOCUS_LAST 2 - -/* Flags for lParam in GTK_WIN32_EMBED_FOCUS_IN, GTK_WIN32_EMBED_FOCUS_NEXT, - * GTK_WIN32_EMBED_FOCUS_PREV - */ -#define GTK_WIN32_EMBED_FOCUS_WRAPAROUND (1 << 0) - -guint _gtk_win32_embed_message_type (GtkWin32EmbedMessageType type); -void _gtk_win32_embed_push_message (MSG *msg); -void _gtk_win32_embed_pop_message (void); -void _gtk_win32_embed_send (GdkWindow *recipient, - GtkWin32EmbedMessageType message, - WPARAM wparam, - LPARAM lparam); -void _gtk_win32_embed_send_focus_message (GdkWindow *recipient, - GtkWin32EmbedMessageType message, - WPARAM wparam); -void _gtk_win32_embed_set_focus_wrapped (void); -gboolean _gtk_win32_embed_get_focus_wrapped (void); - -G_END_DECLS - -#endif /* __GTK_WIN32_EMBED_H__ */ diff --git a/gtk/gtkwin32embedwidget.c b/gtk/gtkwin32embedwidget.c deleted file mode 100644 index f6ddfa1b96..0000000000 --- a/gtk/gtkwin32embedwidget.c +++ /dev/null @@ -1,385 +0,0 @@ -/* GTK - The GIMP Toolkit - * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library. If not, see .Free - */ - -/* - * Modified by the GTK+ Team and others 1997-2006. See the AUTHORS - * file for a list of people on the GTK+ Team. See the ChangeLog - * files for a list of changes. These files are distributed with - * GTK+ at ftp://ftp.gtk.org/pub/gtk/. - */ - -#include "config.h" - -#include "gtkmain.h" -#include "gtkmarshalers.h" -#include "gtksizerequest.h" -#include "gtkwin32embedwidget.h" -#include "gtkintl.h" -#include "gtkprivate.h" -#include "gtkwindowprivate.h" -#include "gtkwidgetprivate.h" -#include "gtkcontainerprivate.h" - - -static void gtk_win32_embed_widget_realize (GtkWidget *widget); -static void gtk_win32_embed_widget_unrealize (GtkWidget *widget); -static void gtk_win32_embed_widget_show (GtkWidget *widget); -static void gtk_win32_embed_widget_hide (GtkWidget *widget); -static void gtk_win32_embed_widget_map (GtkWidget *widget); -static void gtk_win32_embed_widget_unmap (GtkWidget *widget); -static void gtk_win32_embed_widget_size_allocate (GtkWidget *widget, - GtkAllocation *allocation); -static void gtk_win32_embed_widget_set_focus (GtkWindow *window, - GtkWidget *focus); -static gboolean gtk_win32_embed_widget_focus (GtkWidget *widget, - GtkDirectionType direction); -static void gtk_win32_embed_widget_check_resize (GtkContainer *container); - -static GtkBinClass *bin_class = NULL; - -G_DEFINE_TYPE (GtkWin32EmbedWidget, gtk_win32_embed_widget, GTK_TYPE_WINDOW) - -static void -gtk_win32_embed_widget_class_init (GtkWin32EmbedWidgetClass *class) -{ - GtkWidgetClass *widget_class = (GtkWidgetClass *)class; - GtkWindowClass *window_class = (GtkWindowClass *)class; - GtkContainerClass *container_class = (GtkContainerClass *)class; - - bin_class = g_type_class_peek (GTK_TYPE_BIN); - - widget_class->realize = gtk_win32_embed_widget_realize; - widget_class->unrealize = gtk_win32_embed_widget_unrealize; - - widget_class->show = gtk_win32_embed_widget_show; - widget_class->hide = gtk_win32_embed_widget_hide; - widget_class->map = gtk_win32_embed_widget_map; - widget_class->unmap = gtk_win32_embed_widget_unmap; - widget_class->size_allocate = gtk_win32_embed_widget_size_allocate; - - widget_class->focus = gtk_win32_embed_widget_focus; - - container_class->check_resize = gtk_win32_embed_widget_check_resize; - - window_class->set_focus = gtk_win32_embed_widget_set_focus; -} - -static void -gtk_win32_embed_widget_init (GtkWin32EmbedWidget *embed_widget) -{ - _gtk_widget_set_is_toplevel (GTK_WIDGET (embed_widget), TRUE); -G_GNUC_BEGIN_IGNORE_DEPRECATIONS; - gtk_container_set_resize_mode (GTK_CONTAINER (embed_widget), GTK_RESIZE_QUEUE); -G_GNUC_END_IGNORE_DEPRECATIONS; -} - -GtkWidget* -_gtk_win32_embed_widget_new (HWND parent) -{ - GtkWin32EmbedWidget *embed_widget; - - embed_widget = g_object_new (GTK_TYPE_WIN32_EMBED_WIDGET, NULL); - - embed_widget->parent_window = - gdk_win32_window_lookup_for_display (gdk_display_get_default (), - parent); - - if (!embed_widget->parent_window) - embed_widget->parent_window = - gdk_win32_window_foreign_new_for_display (gdk_display_get_default (), - parent); - - return GTK_WIDGET (embed_widget); -} - -BOOL -_gtk_win32_embed_widget_dialog_procedure (GtkWin32EmbedWidget *embed_widget, - HWND wnd, UINT message, WPARAM wparam, LPARAM lparam) -{ - GtkAllocation allocation; - GtkWidget *widget = GTK_WIDGET (embed_widget); - - if (message == WM_SIZE) - { - allocation.width = LOWORD(lparam); - allocation.height = HIWORD(lparam); - gtk_widget_set_allocation (widget, &allocation); - - gtk_widget_queue_resize (widget); - } - - return 0; -} - -static void -gtk_win32_embed_widget_unrealize (GtkWidget *widget) -{ - GtkWin32EmbedWidget *embed_widget = GTK_WIN32_EMBED_WIDGET (widget); - - embed_widget->old_window_procedure = NULL; - - g_clear_object (&embed_widget->parent_window); - - GTK_WIDGET_CLASS (gtk_win32_embed_widget_parent_class)->unrealize (widget); -} - -static LRESULT CALLBACK -gtk_win32_embed_widget_window_process (HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) -{ - GdkWindow *window; - GtkWin32EmbedWidget *embed_widget; - gpointer user_data; - - window = gdk_win32_window_lookup_for_display (gdk_display_get_default (), hwnd); - if (window == NULL) { - g_warning ("No such window!"); - return 0; - } - gdk_window_get_user_data (window, &user_data); - embed_widget = GTK_WIN32_EMBED_WIDGET (user_data); - - if (msg == WM_GETDLGCODE) { - return DLGC_WANTALLKEYS; - } - - if (embed_widget && embed_widget->old_window_procedure) - return CallWindowProc(embed_widget->old_window_procedure, - hwnd, msg, wparam, lparam); - else - return 0; -} - -static void -gtk_win32_embed_widget_realize (GtkWidget *widget) -{ - GtkWindow *window = GTK_WINDOW (widget); - GtkWin32EmbedWidget *embed_widget = GTK_WIN32_EMBED_WIDGET (widget); - GtkAllocation allocation; - GdkWindow *gdk_window; - GdkWindowAttr attributes; - gint attributes_mask; - LONG_PTR styles; - - gtk_widget_get_allocation (widget, &allocation); - - /* ensure widget tree is properly size allocated */ - if (allocation.x == -1 && allocation.y == -1 && - allocation.width == 1 && allocation.height == 1) - { - GtkRequisition requisition; - GtkAllocation allocation = { 0, 0, 200, 200 }; - - gtk_widget_get_preferred_size (widget, &requisition, NULL); - if (requisition.width || requisition.height) - { - /* non-empty window */ - allocation.width = requisition.width; - allocation.height = requisition.height; - } - gtk_widget_size_allocate (widget, &allocation); - - gtk_widget_queue_resize (widget); - - g_return_if_fail (!gtk_widget_get_realized (widget)); - } - - gtk_widget_set_realized (widget, TRUE); - - gtk_widget_get_allocation (widget, &allocation); - - attributes.window_type = GDK_WINDOW_CHILD; - attributes.title = (gchar *) gtk_window_get_title (window); - attributes.width = allocation.width; - attributes.height = allocation.height; - attributes.wclass = GDK_INPUT_OUTPUT; - - /* this isn't right - we should match our parent's visual/colormap. - * though that will require handling "foreign" colormaps */ - attributes.visual = gtk_widget_get_visual (widget); - attributes.event_mask = gtk_widget_get_events (widget); - attributes.event_mask |= (GDK_EXPOSURE_MASK | - GDK_KEY_PRESS_MASK | - GDK_KEY_RELEASE_MASK | - GDK_ENTER_NOTIFY_MASK | - GDK_LEAVE_NOTIFY_MASK | - GDK_STRUCTURE_MASK | - GDK_FOCUS_CHANGE_MASK); - - attributes_mask = GDK_WA_VISUAL; - attributes_mask |= (attributes.title ? GDK_WA_TITLE : 0); - - gdk_window = gdk_window_new (embed_widget->parent_window, - &attributes, attributes_mask); - gtk_widget_set_window (widget, gdk_window); - gtk_widget_register_window (widget, gdk_window); - - embed_widget->old_window_procedure = (gpointer) - SetWindowLongPtrW(GDK_WINDOW_HWND (gdk_window), - GWLP_WNDPROC, - (LONG_PTR)gtk_win32_embed_widget_window_process); - - /* Enable tab to focus the widget */ - styles = GetWindowLongPtr(GDK_WINDOW_HWND (gdk_window), GWL_STYLE); - SetWindowLongPtrW(GDK_WINDOW_HWND (gdk_window), GWL_STYLE, styles | WS_TABSTOP); - -G_GNUC_BEGIN_IGNORE_DEPRECATIONS; - gtk_style_context_set_background (gtk_widget_get_style_context (widget), - gdk_window); -G_GNUC_END_IGNORE_DEPRECATIONS; -} - -static void -gtk_win32_embed_widget_show (GtkWidget *widget) -{ - _gtk_widget_set_visible_flag (widget, TRUE); - - gtk_widget_realize (widget); - gtk_container_check_resize (GTK_CONTAINER (widget)); - gtk_widget_map (widget); -} - -static void -gtk_win32_embed_widget_hide (GtkWidget *widget) -{ - _gtk_widget_set_visible_flag (widget, FALSE); - gtk_widget_unmap (widget); -} - -static void -gtk_win32_embed_widget_map (GtkWidget *widget) -{ - GtkBin *bin = GTK_BIN (widget); - GtkWidget *child; - - gtk_widget_set_mapped (widget, TRUE); - - child = gtk_bin_get_child (bin); - if (child && - gtk_widget_get_visible (child) && - !gtk_widget_get_mapped (child)) - gtk_widget_map (child); - - gdk_window_show (gtk_widget_get_window (widget)); -} - -static void -gtk_win32_embed_widget_unmap (GtkWidget *widget) -{ - gtk_widget_set_mapped (widget, FALSE); - gdk_window_hide (gtk_widget_get_window (widget)); -} - -static void -gtk_win32_embed_widget_size_allocate (GtkWidget *widget, - GtkAllocation *allocation) -{ - GtkBin *bin = GTK_BIN (widget); - GtkWidget *child; - - gtk_widget_set_allocation (widget, allocation); - - if (gtk_widget_get_realized (widget)) - gdk_window_move_resize (gtk_widget_get_window (widget), - allocation->x, allocation->y, - allocation->width, allocation->height); - - child = gtk_bin_get_child (bin); - if (child && gtk_widget_get_visible (child)) - { - GtkAllocation child_allocation; - - child_allocation.x = gtk_container_get_border_width (GTK_CONTAINER (widget)); - child_allocation.y = child_allocation.x; - child_allocation.width = - MAX (1, (gint)allocation->width - child_allocation.x * 2); - child_allocation.height = - MAX (1, (gint)allocation->height - child_allocation.y * 2); - - gtk_widget_size_allocate (child, &child_allocation); - } -} - -static void -gtk_win32_embed_widget_check_resize (GtkContainer *container) -{ - GTK_CONTAINER_CLASS (bin_class)->check_resize (container); -} - -static gboolean -gtk_win32_embed_widget_focus (GtkWidget *widget, - GtkDirectionType direction) -{ - GtkBin *bin = GTK_BIN (widget); - GtkWin32EmbedWidget *embed_widget = GTK_WIN32_EMBED_WIDGET (widget); - GtkWindow *window = GTK_WINDOW (widget); - GtkContainer *container = GTK_CONTAINER (widget); - GtkWidget *old_focus_child = gtk_container_get_focus_child (container); - GtkWidget *parent; - GtkWidget *child; - - /* We override GtkWindow's behavior, since we don't want wrapping here. - */ - if (old_focus_child) - { - if (gtk_widget_child_focus (old_focus_child, direction)) - return TRUE; - - if (gtk_window_get_focus (window)) - { - /* Wrapped off the end, clear the focus setting for the toplevel */ - parent = gtk_widget_get_parent (gtk_window_get_focus (window)); - while (parent) - { - gtk_container_set_focus_child (GTK_CONTAINER (parent), NULL); - parent = gtk_widget_get_parent (GTK_WIDGET (parent)); - } - - gtk_window_set_focus (GTK_WINDOW (container), NULL); - } - } - else - { - /* Try to focus the first widget in the window */ - child = gtk_bin_get_child (bin); - if (child && gtk_widget_child_focus (child, direction)) - return TRUE; - } - - if (!gtk_container_get_focus_child (GTK_CONTAINER (window))) - { - int backwards = FALSE; - - if (direction == GTK_DIR_TAB_BACKWARD || - direction == GTK_DIR_LEFT) - backwards = TRUE; - - PostMessage(GDK_WINDOW_HWND (embed_widget->parent_window), - WM_NEXTDLGCTL, - backwards, 0); - } - - return FALSE; -} - -static void -gtk_win32_embed_widget_set_focus (GtkWindow *window, - GtkWidget *focus) -{ - GTK_WINDOW_CLASS (gtk_win32_embed_widget_parent_class)->set_focus (window, focus); - - gdk_window_focus (gtk_widget_get_window (GTK_WIDGET(window)), 0); -} diff --git a/gtk/gtkwin32embedwidget.h b/gtk/gtkwin32embedwidget.h deleted file mode 100644 index 57776f3726..0000000000 --- a/gtk/gtkwin32embedwidget.h +++ /dev/null @@ -1,75 +0,0 @@ -/* GTK - The GIMP Toolkit - * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library. If not, see . - */ - -/* - * Modified by the GTK+ Team and others 1997-2006. See the AUTHORS - * file for a list of people on the GTK+ Team. See the ChangeLog - * files for a list of changes. These files are distributed with - * GTK+ at ftp://ftp.gtk.org/pub/gtk/. - */ - -#ifndef __GTK_WIN32_EMBED_WIDGET_H__ -#define __GTK_WIN32_EMBED_WIDGET_H__ - - -#include -#include "win32/gdkwin32.h" - - -G_BEGIN_DECLS - -#define GTK_TYPE_WIN32_EMBED_WIDGET (gtk_win32_embed_widget_get_type ()) -#define GTK_WIN32_EMBED_WIDGET(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_WIN32_EMBED_WIDGET, GtkWin32EmbedWidget)) -#define GTK_WIN32_EMBED_WIDGET_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_WIN32_EMBED_WIDGET, GtkWin32EmbedWidgetClass)) -#define GTK_IS_WIN32_EMBED_WIDGET(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_WIN32_EMBED_WIDGET)) -#define GTK_IS_WIN32_EMBED_WIDGET_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_WIN32_EMBED_WIDGET)) -#define GTK_WIN32_EMBED_WIDGET_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_WIN32_EMBED_WIDGET, GtkWin32EmbedWidgetClass)) - - -typedef struct _GtkWin32EmbedWidget GtkWin32EmbedWidget; -typedef struct _GtkWin32EmbedWidgetClass GtkWin32EmbedWidgetClass; - - -struct _GtkWin32EmbedWidget -{ - GtkWindow window; - - GdkWindow *parent_window; - gpointer old_window_procedure; -}; - -struct _GtkWin32EmbedWidgetClass -{ - GtkWindowClass parent_class; - - /* Padding for future expansion */ - void (*_gtk_reserved1) (void); - void (*_gtk_reserved2) (void); - void (*_gtk_reserved3) (void); - void (*_gtk_reserved4) (void); -}; - - -GType gtk_win32_embed_widget_get_type (void) G_GNUC_CONST; -GtkWidget* _gtk_win32_embed_widget_new (HWND parent); -BOOL _gtk_win32_embed_widget_dialog_procedure (GtkWin32EmbedWidget *embed_widget, - HWND wnd, UINT message, WPARAM wparam, LPARAM lparam); - - -G_END_DECLS - -#endif /* __GTK_WIN32_EMBED_WIDGET_H__ */ diff --git a/gtk/gtkwindow.c b/gtk/gtkwindow.c index e77060da84..600951b3aa 100644 --- a/gtk/gtkwindow.c +++ b/gtk/gtkwindow.c @@ -46,7 +46,6 @@ #include "gtkmenushellprivate.h" #include "gtkicontheme.h" #include "gtkmarshalers.h" -#include "gtkplug.h" #include "gtkbuildable.h" #include "gtkbuilderprivate.h" #include "gtkwidgetprivate.h" @@ -1712,17 +1711,10 @@ gtk_window_constructed (GObject *object) { GtkWindow *window = GTK_WINDOW (object); GtkWindowPrivate *priv = window->priv; - gboolean is_plug; G_OBJECT_CLASS (gtk_window_parent_class)->constructed (object); -#ifdef GDK_WINDOWING_X11 - is_plug = GTK_IS_PLUG (window); -#else - is_plug = FALSE; -#endif - - if (priv->type == GTK_WINDOW_TOPLEVEL && !is_plug) + if (priv->type == GTK_WINDOW_TOPLEVEL) { priv->multipress_gesture = gtk_gesture_multi_press_new (GTK_WIDGET (object)); gtk_gesture_single_set_button (GTK_GESTURE_SINGLE (priv->multipress_gesture), 0); @@ -5977,7 +5969,6 @@ gtk_window_show (GtkWidget *widget) GtkWindow *window = GTK_WINDOW (widget); GtkWindowPrivate *priv = window->priv; GtkContainer *container = GTK_CONTAINER (window); - gboolean is_plug; if (!_gtk_widget_is_toplevel (GTK_WIDGET (widget))) { @@ -5995,15 +5986,7 @@ gtk_window_show (GtkWidget *widget) gtk_widget_map (widget); - /* Try to make sure that we have some focused widget - */ -#ifdef GDK_WINDOWING_X11 - is_plug = GDK_IS_X11_WINDOW (_gtk_widget_get_window (widget)) && - GTK_IS_PLUG (window); -#else - is_plug = FALSE; -#endif - if (!priv->focus_widget && !is_plug) + if (!priv->focus_widget) { if (priv->initial_focus) gtk_window_set_focus (window, priv->initial_focus); @@ -10768,8 +10751,7 @@ _gtk_window_get_screen (GtkWindow *window) * * Returns whether the window is part of the current active toplevel. * (That is, the toplevel window receiving keystrokes.) - * The return value is %TRUE if the window is active toplevel - * itself, but also if it is, say, a #GtkPlug embedded in the active toplevel. + * The return value is %TRUE if the window is active toplevel itself. * You might use this function if you wanted to draw a widget * differently in an active window from a widget in an inactive window. * See gtk_window_has_toplevel_focus() diff --git a/gtk/gtkx-autocleanups.h b/gtk/gtkx-autocleanups.h deleted file mode 100644 index bc200a0207..0000000000 --- a/gtk/gtkx-autocleanups.h +++ /dev/null @@ -1,31 +0,0 @@ -/* GTK - The GIMP Toolkit - * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library. If not, see . - */ - -#if !defined (__GTKX_H_INSIDE__) && !defined (GTK_COMPILATION) -#error "Only can be included directly." -#endif - -#ifdef GDK_WINDOWING_X11 - -#ifndef __GI_SCANNER__ - -G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkSocket, g_object_unref) -G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkPlug, g_object_unref) - -#endif - -#endif diff --git a/gtk/gtkx.h b/gtk/gtkx.h deleted file mode 100644 index f7bce4fef6..0000000000 --- a/gtk/gtkx.h +++ /dev/null @@ -1,36 +0,0 @@ -/* GTK - The GIMP Toolkit - * Copyright (C) 2011 Red Hat, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library. If not, see . - */ - -#ifndef __GTK_X_H__ -#define __GTK_X_H__ - -#if defined (GTK_COMPILATION) -#error " must not be included by GTK+ headers." -#endif - -#define __GTKX_H_INSIDE__ - -#include - -#include -#include - -#include - -#undef __GTKX_H_INSIDE__ - -#endif /* __GTK_X_H__ */ diff --git a/gtk/gtkxembed.c b/gtk/gtkxembed.c deleted file mode 100644 index 8634d6625f..0000000000 --- a/gtk/gtkxembed.c +++ /dev/null @@ -1,242 +0,0 @@ -/* GTK - The GIMP Toolkit - * gtkxembed.c: Utilities for the XEMBED protocol - * Copyright (C) 2001, 2003, Red Hat, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library. If not, see . - */ - -#include "config.h" -#include -#include "gtkmain.h" -#include "gtkprivate.h" -#include "gtkxembed.h" -#include "gtkdebug.h" - - -typedef struct _GtkXEmbedMessage GtkXEmbedMessage; - -struct _GtkXEmbedMessage -{ - glong message; - glong detail; - glong data1; - glong data2; - guint32 time; -}; - -static GSList *current_messages; - - -/** - * _gtk_xembed_push_message: - * @xevent: a XEvent - * - * Adds a client message to the stack of current XEMBED events. - **/ -void -_gtk_xembed_push_message (XEvent *xevent) -{ - GtkXEmbedMessage *message = g_slice_new (GtkXEmbedMessage); - - message->time = xevent->xclient.data.l[0]; - message->message = xevent->xclient.data.l[1]; - message->detail = xevent->xclient.data.l[2]; - message->data1 = xevent->xclient.data.l[3]; - message->data2 = xevent->xclient.data.l[4]; - - current_messages = g_slist_prepend (current_messages, message); -} - -/** - * _gtk_xembed_pop_message: - * - * Removes an event added with _gtk_xembed_push_message() - **/ -void -_gtk_xembed_pop_message (void) -{ - GtkXEmbedMessage *message = current_messages->data; - current_messages = g_slist_delete_link (current_messages, current_messages); - g_slice_free (GtkXEmbedMessage, message); -} - -/** - * _gtk_xembed_set_focus_wrapped: - * - * Sets a flag indicating that the current focus sequence wrapped - * around to the beginning of the ultimate toplevel. - **/ -void -_gtk_xembed_set_focus_wrapped (void) -{ - GtkXEmbedMessage *message; - - g_return_if_fail (current_messages != NULL); - message = current_messages->data; - g_return_if_fail (message->message == XEMBED_FOCUS_PREV || message->message == XEMBED_FOCUS_NEXT); - - message->data1 |= XEMBED_FOCUS_WRAPAROUND; -} - -/** - * _gtk_xembed_get_focus_wrapped: - * - * Gets whether the current focus sequence has wrapped around - * to the beginning of the ultimate toplevel. - * - * Returns: %TRUE if the focus sequence has wrapped around. - **/ -gboolean -_gtk_xembed_get_focus_wrapped (void) -{ - GtkXEmbedMessage *message; - - g_return_val_if_fail (current_messages != NULL, FALSE); - message = current_messages->data; - - return (message->data1 & XEMBED_FOCUS_WRAPAROUND) != 0; -} - -static guint32 -gtk_xembed_get_time (void) -{ - if (current_messages) - { - GtkXEmbedMessage *message = current_messages->data; - return message->time; - } - else - return gtk_get_current_event_time (); -} - -/** - * _gtk_xembed_send_message: - * @recipient: (allow-none): window to which to send the window, or %NULL - * in which case nothing will be sent - * @message: type of message - * @detail: detail field of message - * @data1: data1 field of message - * @data2: data2 field of message - * - * Sends a generic XEMBED message to a particular window. - **/ -void -_gtk_xembed_send_message (GdkWindow *recipient, - XEmbedMessageType message, - glong detail, - glong data1, - glong data2) -{ - GdkDisplay *display; - XClientMessageEvent xclient; - - if (!recipient) - return; - - g_return_if_fail (GDK_IS_WINDOW (recipient)); - - display = gdk_window_get_display (recipient); - GTK_NOTE (PLUGSOCKET, - g_message ("Sending %s", _gtk_xembed_message_name (message))); - - memset (&xclient, 0, sizeof (xclient)); - xclient.window = GDK_WINDOW_XID (recipient); - xclient.type = ClientMessage; - xclient.message_type = gdk_x11_get_xatom_by_name_for_display (display, "_XEMBED"); - xclient.format = 32; - xclient.data.l[0] = gtk_xembed_get_time (); - xclient.data.l[1] = message; - xclient.data.l[2] = detail; - xclient.data.l[3] = data1; - xclient.data.l[4] = data2; - - gdk_error_trap_push (); - XSendEvent (GDK_WINDOW_XDISPLAY(recipient), - GDK_WINDOW_XID (recipient), - False, NoEventMask, (XEvent *)&xclient); - gdk_error_trap_pop_ignored (); -} - -/** - * _gtk_xembed_send_focus_message: - * @recipient: (allow-none): window to which to send the window, or %NULL - * in which case nothing will be sent - * @message_type: type of message - * @detail: detail field of message - * - * Sends a XEMBED message for moving the focus along the focus - * chain to a window. The flags field that these messages share - * will be correctly filled in. - **/ -void -_gtk_xembed_send_focus_message (GdkWindow *recipient, - XEmbedMessageType message_type, - glong detail) -{ - gulong flags = 0; - - if (!recipient) - return; - - g_return_if_fail (GDK_IS_WINDOW (recipient)); - g_return_if_fail (message_type == XEMBED_FOCUS_IN || - message_type == XEMBED_FOCUS_NEXT || - message_type == XEMBED_FOCUS_PREV); - - if (current_messages) - { - GtkXEmbedMessage *message = current_messages->data; - switch (message->message) - { - case XEMBED_FOCUS_IN: - case XEMBED_FOCUS_NEXT: - case XEMBED_FOCUS_PREV: - flags = message->data1 & XEMBED_FOCUS_WRAPAROUND; - break; - default: - break; - } - } - - _gtk_xembed_send_message (recipient, message_type, detail, flags, 0); -} - -const char * -_gtk_xembed_message_name (XEmbedMessageType message) -{ - static char unk[24]; - - switch (message) - { -#define CASE(x) case XEMBED_##x: return "XEMBED_"#x - CASE (EMBEDDED_NOTIFY); - CASE (WINDOW_ACTIVATE); - CASE (WINDOW_DEACTIVATE); - CASE (REQUEST_FOCUS); - CASE (FOCUS_IN); - CASE (FOCUS_OUT); - CASE (FOCUS_NEXT); - CASE (FOCUS_PREV); - CASE (GRAB_KEY); - CASE (UNGRAB_KEY); - CASE (MODALITY_ON); - CASE (MODALITY_OFF); - CASE (GTK_GRAB_KEY); - CASE (GTK_UNGRAB_KEY); -#undef CASE - default: - snprintf (unk, 24, "UNKNOWN(%d)", message); - return unk; - } -} diff --git a/gtk/gtkxembed.h b/gtk/gtkxembed.h deleted file mode 100644 index 4833288967..0000000000 --- a/gtk/gtkxembed.h +++ /dev/null @@ -1,47 +0,0 @@ -/* GTK - The GIMP Toolkit - * gtkxembed.c: Utilities for the XEMBED protocol - * Copyright (C) 2003, Red Hat, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library. If not, see . - */ - -#ifndef __GTK_XEMBED_H__ -#define __GTK_XEMBED_H__ - -#include "xembed.h" -#include "x11/gdkx.h" - -G_BEGIN_DECLS - -/* Latest version we implement */ -#define GTK_XEMBED_PROTOCOL_VERSION 1 - -void _gtk_xembed_send_message (GdkWindow *recipient, - XEmbedMessageType message, - glong detail, - glong data1, - glong data2); -void _gtk_xembed_send_focus_message (GdkWindow *recipient, - XEmbedMessageType message, - glong detail); - -void _gtk_xembed_push_message (XEvent *xevent); -void _gtk_xembed_pop_message (void); -void _gtk_xembed_set_focus_wrapped (void); -gboolean _gtk_xembed_get_focus_wrapped (void); -const char *_gtk_xembed_message_name (XEmbedMessageType message); - -G_END_DECLS - -#endif /* __GTK_XEMBED_H__ */ diff --git a/gtk/makefile.msc.in b/gtk/makefile.msc.in index 17ff80cd90..ad9934b2e7 100644 --- a/gtk/makefile.msc.in +++ b/gtk/makefile.msc.in @@ -445,7 +445,6 @@ gtk_public_h_sources = \ gtkpagesetup.h \ gtkpaned.h \ gtkpapersize.h \ - gtkplug.h \ gtkprintcontext.h \ gtkprintoperation.h \ gtkprintoperationpreview.h \ @@ -478,7 +477,6 @@ gtk_public_h_sources = \ gtkstacksidebar.h \ gtksizegroup.h \ gtksizerequest.h \ - gtksocket.h \ gtkspinbutton.h \ gtkspinner.h \ gtkstatusbar.h \ diff --git a/po-properties/POTFILES.in b/po-properties/POTFILES.in index b983e01e11..a4b84a9dc2 100644 --- a/po-properties/POTFILES.in +++ b/po-properties/POTFILES.in @@ -216,7 +216,6 @@ gtk/gtkpathbar.c gtk/gtkplacessidebar.c gtk/gtkplacesview.c gtk/gtkplacesviewrow.c -gtk/gtkplug.c gtk/gtkpopover.c gtk/gtkpopovermenu.c gtk/gtkprintbackend.c @@ -259,7 +258,6 @@ gtk/gtkshortcutssection.c gtk/gtkshortcutsshortcut.c gtk/gtkshortcutswindow.c gtk/gtksizegroup.c -gtk/gtksocket.c gtk/gtkspinbutton.c gtk/gtkspinner.c gtk/gtkstack.c diff --git a/po/POTFILES.in b/po/POTFILES.in index 6aa8a4e841..9019554b0a 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -217,7 +217,6 @@ gtk/gtkpathbar.c gtk/gtkplacessidebar.c gtk/gtkplacesview.c gtk/gtkplacesviewrow.c -gtk/gtkplug.c gtk/gtkpopover.c gtk/gtkpopovermenu.c gtk/gtkprintbackend.c @@ -261,7 +260,6 @@ gtk/gtkshortcutsshortcut.c gtk/gtkshortcutswindow.c gtk/gtksizegroup.c gtk/gtksizerequest.c -gtk/gtksocket.c gtk/gtkspinbutton.c gtk/gtkspinner.c gtk/gtkstack.c diff --git a/tests/Makefile.am b/tests/Makefile.am index c887928b45..f3522de3f7 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -22,10 +22,6 @@ LDADD = \ -lm -if USE_X11 -testsocket_programs = testsocket testsocket_child -endif - if OS_LINUX fontconfig_programs = testfontchooserdialog endif @@ -113,7 +109,6 @@ noinst_PROGRAMS = $(TEST_PROGS) \ testscale \ testselection \ testselectionmode \ - $(testsocket_programs) \ testspinbutton \ teststockbuttonmenu \ testtoolbar \ @@ -246,8 +241,6 @@ testrecentchoosermenu_DEPENDENCIES = $(TEST_DEPS) testrichtext_DEPENDENCIES = $(TEST_DEPS) testscale_DEPENDENCIES = $(TEST_DEPS) testselection_DEPENDENCIES = $(TEST_DEPS) -testsocket_DEPENDENCIES = $(DEPS) -testsocket_child_DEPENDENCIES = $(DEPS) testspinbutton_DEPENDENCIES = $(TEST_DEPS) teststockbuttonmenu_DEPENDENCIES = $(TEST_DEPS) testtreechanging_DEPENDENCIES = $(DEPS) @@ -391,14 +384,6 @@ testprint_SOURCES = \ testprintfileoperation.h \ testprintfileoperation.c -testsocket_SOURCES = \ - testsocket.c \ - testsocket_common.c - -testsocket_child_SOURCES = \ - testsocket_child.c \ - testsocket_common.c - testspinbutton_SOURCES = \ testspinbutton.c diff --git a/tests/testsocket.c b/tests/testsocket.c deleted file mode 100644 index b250f10729..0000000000 --- a/tests/testsocket.c +++ /dev/null @@ -1,404 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 2 -*- */ -/* testsocket.c - * Copyright (C) 2001 Red Hat, Inc - * Author: Owen Taylor - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library. If not, see . - */ - -#include "config.h" -#include -#include - -#include -#include -#include - -int n_children = 0; - -GSList *sockets = NULL; - -GtkWidget *window; -GtkWidget *box; - -typedef struct -{ - GtkWidget *box; - GtkWidget *frame; - GtkWidget *socket; -} Socket; - -extern guint32 create_child_plug (guint32 xid, - gboolean local); - -static void -quit_cb (gpointer callback_data, - guint callback_action, - GtkWidget *widget) -{ - GtkWidget *message_dialog = gtk_message_dialog_new (GTK_WINDOW (window), 0, - GTK_MESSAGE_QUESTION, - GTK_BUTTONS_YES_NO, - "Really Quit?"); - gtk_dialog_set_default_response (GTK_DIALOG (message_dialog), GTK_RESPONSE_NO); - - if (gtk_dialog_run (GTK_DIALOG (message_dialog)) == GTK_RESPONSE_YES) - gtk_widget_destroy (window); - - gtk_widget_destroy (message_dialog); -} - -static void -socket_destroyed (GtkWidget *widget, - Socket *socket) -{ - sockets = g_slist_remove (sockets, socket); - g_free (socket); -} - -static void -plug_added (GtkWidget *widget, - Socket *socket) -{ - g_print ("Plug added to socket\n"); - - gtk_widget_show (socket->socket); - gtk_widget_hide (socket->frame); -} - -static gboolean -plug_removed (GtkWidget *widget, - Socket *socket) -{ - g_print ("Plug removed from socket\n"); - - gtk_widget_hide (socket->socket); - gtk_widget_show (socket->frame); - - return TRUE; -} - -static Socket * -create_socket (void) -{ - GtkWidget *label; - - Socket *socket = g_new (Socket, 1); - - socket->box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0); - - socket->socket = gtk_socket_new (); - - gtk_box_pack_start (GTK_BOX (socket->box), socket->socket, TRUE, TRUE, 0); - - socket->frame = gtk_frame_new (NULL); - gtk_frame_set_shadow_type (GTK_FRAME (socket->frame), GTK_SHADOW_IN); - gtk_box_pack_start (GTK_BOX (socket->box), socket->frame, TRUE, TRUE, 0); - gtk_widget_show (socket->frame); - - label = gtk_label_new (NULL); - gtk_label_set_markup (GTK_LABEL (label), "Empty"); - gtk_container_add (GTK_CONTAINER (socket->frame), label); - gtk_widget_show (label); - - sockets = g_slist_prepend (sockets, socket); - - - g_signal_connect (socket->socket, "destroy", - G_CALLBACK (socket_destroyed), socket); - g_signal_connect (socket->socket, "plug_added", - G_CALLBACK (plug_added), socket); - g_signal_connect (socket->socket, "plug_removed", - G_CALLBACK (plug_removed), socket); - - return socket; -} - -void -remove_child (GtkWidget *window) -{ - if (sockets) - { - Socket *socket = sockets->data; - gtk_widget_destroy (socket->box); - } -} - -static gboolean -child_read_watch (GIOChannel *channel, GIOCondition cond, gpointer data) -{ - GIOStatus status; - GError *error = NULL; - char *line; - gsize term; - int xid; - - status = g_io_channel_read_line (channel, &line, NULL, &term, &error); - switch (status) - { - case G_IO_STATUS_NORMAL: - line[term] = '\0'; - xid = strtol (line, NULL, 0); - if (xid == 0) - { - fprintf (stderr, "Invalid window id '%s'\n", line); - } - else - { - Socket *socket = create_socket (); - gtk_box_pack_start (GTK_BOX (box), socket->box, TRUE, TRUE, 0); - gtk_widget_show (socket->box); - - gtk_socket_add_id (GTK_SOCKET (socket->socket), xid); - } - g_free (line); - return TRUE; - case G_IO_STATUS_AGAIN: - return TRUE; - case G_IO_STATUS_EOF: - n_children--; - return FALSE; - case G_IO_STATUS_ERROR: - fprintf (stderr, "Error reading fd from child: %s\n", error->message); - exit (1); - return FALSE; - default: - g_assert_not_reached (); - return FALSE; - } - -} - -void -add_child (GtkWidget *window, - gboolean active) -{ - Socket *socket; - char *argv[3] = { "./testsocket_child", NULL, NULL }; - char buffer[20]; - int out_fd; - GIOChannel *channel; - GError *error = NULL; - - if (active) - { - socket = create_socket (); - gtk_box_pack_start (GTK_BOX (box), socket->box, TRUE, TRUE, 0); - gtk_widget_show (socket->box); - sprintf(buffer, "%#lx", (gulong) gtk_socket_get_id (GTK_SOCKET (socket->socket))); - argv[1] = buffer; - } - - if (!g_spawn_async_with_pipes (NULL, argv, NULL, 0, NULL, NULL, NULL, NULL, &out_fd, NULL, &error)) - { - fprintf (stderr, "Can't exec testsocket_child: %s\n", error->message); - exit (1); - } - - n_children++; - channel = g_io_channel_unix_new (out_fd); - g_io_channel_set_close_on_unref (channel, TRUE); - g_io_channel_set_flags (channel, G_IO_FLAG_NONBLOCK, &error); - if (error) - { - fprintf (stderr, "Error making channel non-blocking: %s\n", error->message); - exit (1); - } - - g_io_add_watch (channel, G_IO_IN | G_IO_HUP, child_read_watch, NULL); - g_io_channel_unref (channel); -} - -void -add_active_child (GtkWidget *window) -{ - add_child (window, TRUE); -} - -void -add_passive_child (GtkWidget *window) -{ - add_child (window, FALSE); -} - -void -add_local_active_child (GtkWidget *window) -{ - Socket *socket; - - socket = create_socket (); - gtk_box_pack_start (GTK_BOX (box), socket->box, TRUE, TRUE, 0); - gtk_widget_show (socket->box); - - create_child_plug (gtk_socket_get_id (GTK_SOCKET (socket->socket)), TRUE); -} - -void -add_local_passive_child (GtkWidget *window) -{ - Socket *socket; - Window xid; - - socket = create_socket (); - gtk_box_pack_start (GTK_BOX (box), socket->box, TRUE, TRUE, 0); - gtk_widget_show (socket->box); - - xid = create_child_plug (0, TRUE); - gtk_socket_add_id (GTK_SOCKET (socket->socket), xid); -} - -static const char * -grab_string (int status) -{ - switch (status) { - case GDK_GRAB_SUCCESS: return "GrabSuccess"; - case GDK_GRAB_ALREADY_GRABBED: return "AlreadyGrabbed"; - case GDK_GRAB_INVALID_TIME: return "GrabInvalidTime"; - case GDK_GRAB_NOT_VIEWABLE: return "GrabNotViewable"; - case GDK_GRAB_FROZEN: return "GrabFrozen"; - default: - { - static char foo [255]; - sprintf (foo, "unknown status: %d", status); - return foo; - } - } -} - -static void -grab_window_toggled (GtkToggleButton *button, - GtkWidget *widget) -{ - GdkDevice *device = gtk_get_current_event_device (); - GdkSeat *seat = gdk_device_get_seat (device); - - if (gtk_toggle_button_get_active (button)) - { - int status; - - status = gdk_seat_grab (seat, gtk_widget_get_window (widget), - GDK_SEAT_CAPABILITY_KEYBOARD, - FALSE, NULL, NULL, NULL, NULL); - - if (status != GDK_GRAB_SUCCESS) - g_warning ("Could not grab keyboard! (%s)", grab_string (status)); - - } - else - { - gdk_seat_ungrab (seat); - } -} - -int -main (int argc, char *argv[]) -{ - GtkWidget *button; - GtkWidget *hbox; - GtkWidget *vbox; - GtkWidget *menubar; - GtkWidget *menuitem; - GtkWidget *menu; - GtkWidget *entry; - GtkWidget *checkbutton; - GtkAccelGroup *accel_group; - - gtk_init (&argc, &argv); - - window = gtk_window_new (GTK_WINDOW_TOPLEVEL); - g_signal_connect (window, "destroy", - G_CALLBACK (gtk_main_quit), NULL); - - gtk_window_set_title (GTK_WINDOW (window), "Socket Test"); - gtk_container_set_border_width (GTK_CONTAINER (window), 0); - - vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0); - gtk_container_add (GTK_CONTAINER (window), vbox); - - menubar = gtk_menu_bar_new (); - menuitem = gtk_menu_item_new_with_mnemonic ("_File"); - gtk_menu_shell_append (GTK_MENU_SHELL (menubar), menuitem); - - menu = gtk_menu_new (); - gtk_menu_item_set_submenu (GTK_MENU_ITEM (menuitem), menu); - menuitem = gtk_menu_item_new_with_mnemonic ("_Quit"); - g_signal_connect (menuitem, "activate", G_CALLBACK (quit_cb), window); - gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem); - - accel_group = gtk_accel_group_new (); - gtk_window_add_accel_group (GTK_WINDOW (window), accel_group); - gtk_box_pack_start (GTK_BOX (vbox), menubar, FALSE, FALSE, 0); - - button = gtk_button_new_with_label ("Add Active Child"); - gtk_box_pack_start (GTK_BOX(vbox), button, FALSE, FALSE, 0); - - g_signal_connect_swapped (button, "clicked", - G_CALLBACK (add_active_child), vbox); - - button = gtk_button_new_with_label ("Add Passive Child"); - gtk_box_pack_start (GTK_BOX(vbox), button, FALSE, FALSE, 0); - - g_signal_connect_swapped (button, "clicked", - G_CALLBACK (add_passive_child), vbox); - - button = gtk_button_new_with_label ("Add Local Active Child"); - gtk_box_pack_start (GTK_BOX(vbox), button, FALSE, FALSE, 0); - - g_signal_connect_swapped (button, "clicked", - G_CALLBACK (add_local_active_child), vbox); - - button = gtk_button_new_with_label ("Add Local Passive Child"); - gtk_box_pack_start (GTK_BOX(vbox), button, FALSE, FALSE, 0); - - g_signal_connect_swapped (button, "clicked", - G_CALLBACK (add_local_passive_child), vbox); - - button = gtk_button_new_with_label ("Remove Last Child"); - gtk_box_pack_start (GTK_BOX(vbox), button, FALSE, FALSE, 0); - - g_signal_connect_swapped (button, "clicked", - G_CALLBACK (remove_child), vbox); - - checkbutton = gtk_check_button_new_with_label ("Grab keyboard"); - gtk_box_pack_start (GTK_BOX (vbox), checkbutton, FALSE, FALSE, 0); - - g_signal_connect (checkbutton, "toggled", - G_CALLBACK (grab_window_toggled), - window); - - hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0); - gtk_box_pack_start (GTK_BOX(vbox), hbox, FALSE, FALSE, 0); - - entry = gtk_entry_new (); - gtk_box_pack_start (GTK_BOX(hbox), entry, FALSE, FALSE, 0); - - hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0); - gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0); - - box = hbox; - - gtk_widget_show_all (window); - - gtk_main (); - - if (n_children) - { - g_print ("Waiting for children to exit\n"); - - while (n_children) - g_main_context_iteration (NULL, TRUE); - } - - return 0; -} diff --git a/tests/testsocket_child.c b/tests/testsocket_child.c deleted file mode 100644 index 1b8934ef52..0000000000 --- a/tests/testsocket_child.c +++ /dev/null @@ -1,65 +0,0 @@ -/* testsocket_child.c - * Copyright (C) 2001 Red Hat, Inc - * Author: Owen Taylor - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library. If not, see . - */ - -#include "config.h" -#include -#include - -#include - -extern guint32 create_child_plug (guint32 xid, - gboolean local); - -int -main (int argc, char *argv[]) -{ - guint32 xid; - guint32 plug_xid; - - gtk_init (&argc, &argv); - - if (argc != 1 && argc != 2) - { - fprintf (stderr, "Usage: testsocket_child [WINDOW_ID]\n"); - exit (1); - } - - if (argc == 2) - { - xid = strtol (argv[1], NULL, 0); - if (xid == 0) - { - fprintf (stderr, "Invalid window id '%s'\n", argv[1]); - exit (1); - } - - create_child_plug (xid, FALSE); - } - else - { - plug_xid = create_child_plug (0, FALSE); - printf ("%d\n", plug_xid); - fflush (stdout); - } - - gtk_main (); - - return 0; -} - - diff --git a/tests/testsocket_common.c b/tests/testsocket_common.c deleted file mode 100644 index a52632192a..0000000000 --- a/tests/testsocket_common.c +++ /dev/null @@ -1,286 +0,0 @@ -/* testsocket_common.c - * Copyright (C) 2001 Red Hat, Inc - * Author: Owen Taylor - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library. If not, see . - */ - -#include "config.h" -#include -#if defined (GDK_WINDOWING_X11) -#include -#elif defined (GDK_WINDOWING_WIN32) -#include "win32/gdkwin32.h" -#endif - -enum -{ - ACTION_FILE_NEW, - ACTION_FILE_OPEN, - ACTION_OK, - ACTION_HELP_ABOUT -}; - -static void -print_hello (GtkWidget *w, - guint action) -{ - switch (action) - { - case ACTION_FILE_NEW: - g_message ("File New activated"); - break; - case ACTION_FILE_OPEN: - g_message ("File Open activated"); - break; - case ACTION_OK: - g_message ("OK activated"); - break; - case ACTION_HELP_ABOUT: - g_message ("Help About activated "); - break; - default: - g_assert_not_reached (); - break; - } -} - -static void -remove_buttons (GtkWidget *widget, GtkWidget *other_button) -{ - gtk_widget_destroy (other_button); - gtk_widget_destroy (widget); -} - -static gboolean -blink_cb (gpointer data) -{ - GtkWidget *widget = data; - - gtk_widget_show (widget); - g_object_set_data (G_OBJECT (widget), "blink", NULL); - - return FALSE; -} - -static void -blink (GtkWidget *widget, - GtkWidget *window) -{ - guint blink_timeout = GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (window), "blink")); - - if (!blink_timeout) - { - blink_timeout = gdk_threads_add_timeout (1000, blink_cb, window); - gtk_widget_hide (window); - - g_object_set_data (G_OBJECT (window), "blink", GUINT_TO_POINTER (blink_timeout)); - } -} - -static void -local_destroy (GtkWidget *window) -{ - guint blink_timeout = GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (window), "blink")); - if (blink_timeout) - g_source_remove (blink_timeout); -} - -static void -remote_destroy (GtkWidget *window) -{ - local_destroy (window); - gtk_main_quit (); -} - -static void -add_buttons (GtkWidget *widget, GtkWidget *box) -{ - GtkWidget *add_button; - GtkWidget *remove_button; - - add_button = gtk_button_new_with_mnemonic ("_Add"); - gtk_box_pack_start (GTK_BOX (box), add_button, TRUE, TRUE, 0); - gtk_widget_show (add_button); - - g_signal_connect (add_button, "clicked", - G_CALLBACK (add_buttons), - box); - - remove_button = gtk_button_new_with_mnemonic ("_Remove"); - gtk_box_pack_start (GTK_BOX (box), remove_button, TRUE, TRUE, 0); - gtk_widget_show (remove_button); - - g_signal_connect (remove_button, "clicked", - G_CALLBACK (remove_buttons), - add_button); -} - -static GtkWidget * -create_combo (void) -{ - GtkComboBoxText *combo; - GtkWidget *entry; - - combo = GTK_COMBO_BOX_TEXT (gtk_combo_box_text_new_with_entry ()); - - gtk_combo_box_text_append_text (combo, "item0"); - gtk_combo_box_text_append_text (combo, "item1 item1"); - gtk_combo_box_text_append_text (combo, "item2 item2 item2"); - gtk_combo_box_text_append_text (combo, "item3 item3 item3 item3"); - gtk_combo_box_text_append_text (combo, "item4 item4 item4 item4 item4"); - gtk_combo_box_text_append_text (combo, "item5 item5 item5 item5 item5 item5"); - gtk_combo_box_text_append_text (combo, "item6 item6 item6 item6 item6"); - gtk_combo_box_text_append_text (combo, "item7 item7 item7 item7"); - gtk_combo_box_text_append_text (combo, "item8 item8 item8"); - gtk_combo_box_text_append_text (combo, "item9 item9"); - - entry = gtk_bin_get_child (GTK_BIN (combo)); - gtk_entry_set_text (GTK_ENTRY (entry), "hello world"); - gtk_editable_select_region (GTK_EDITABLE (entry), 0, -1); - - return GTK_WIDGET (combo); -} - -static GtkWidget * -create_menubar (GtkWindow *window) -{ - GtkAccelGroup *accel_group=NULL; - GtkWidget *menubar; - GtkWidget *menuitem; - GtkWidget *menu; - - accel_group = gtk_accel_group_new (); - gtk_window_add_accel_group (window, accel_group); - - menubar = gtk_menu_bar_new (); - - menuitem = gtk_menu_item_new_with_mnemonic ("_File"); - gtk_menu_shell_append (GTK_MENU_SHELL (menubar), menuitem); - menu = gtk_menu_new (); - gtk_menu_item_set_submenu (GTK_MENU_ITEM (menuitem), menu); - menuitem = gtk_menu_item_new_with_mnemonic ("_New"); - g_signal_connect (menuitem, "activate", G_CALLBACK (print_hello), window); - gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem); - menuitem = gtk_separator_menu_item_new (); - gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem); - menuitem = gtk_menu_item_new_with_mnemonic ("_Quit"); - g_signal_connect (menuitem, "activate", G_CALLBACK (gtk_main_quit), window); - gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem); - - menuitem = gtk_menu_item_new_with_mnemonic ("O_K"); - gtk_menu_shell_append (GTK_MENU_SHELL (menubar), menuitem); - - menuitem = gtk_menu_item_new_with_mnemonic ("_Help"); - gtk_menu_shell_append (GTK_MENU_SHELL (menubar), menuitem); - menu = gtk_menu_new (); - gtk_menu_item_set_submenu (GTK_MENU_ITEM (menuitem), menu); - menuitem = gtk_menu_item_new_with_mnemonic ("_About"); - g_signal_connect (menuitem, "activate", G_CALLBACK (print_hello), window); - gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem); - - return menubar; -} - -static GtkWidget * -create_combo_box (void) -{ - GtkComboBoxText *combo_box = GTK_COMBO_BOX_TEXT (gtk_combo_box_text_new ()); - - gtk_combo_box_text_append_text (combo_box, "This"); - gtk_combo_box_text_append_text (combo_box, "Is"); - gtk_combo_box_text_append_text (combo_box, "A"); - gtk_combo_box_text_append_text (combo_box, "ComboBox"); - - return GTK_WIDGET (combo_box); -} - -static GtkWidget * -create_content (GtkWindow *window, gboolean local) -{ - GtkWidget *vbox; - GtkWidget *button; - GtkWidget *frame; - - frame = gtk_frame_new (local? "Local" : "Remote"); - gtk_container_set_border_width (GTK_CONTAINER (frame), 3); - vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0); - gtk_box_set_homogeneous (GTK_BOX (vbox), TRUE); - gtk_container_set_border_width (GTK_CONTAINER (vbox), 3); - - gtk_container_add (GTK_CONTAINER (frame), vbox); - - /* Combo */ - gtk_box_pack_start (GTK_BOX (vbox), create_combo(), TRUE, TRUE, 0); - - /* Entry */ - gtk_box_pack_start (GTK_BOX (vbox), gtk_entry_new(), TRUE, TRUE, 0); - - /* Close Button */ - button = gtk_button_new_with_mnemonic ("_Close"); - gtk_box_pack_start (GTK_BOX (vbox), button, TRUE, TRUE, 0); - g_signal_connect_swapped (button, "clicked", - G_CALLBACK (gtk_widget_destroy), window); - - /* Blink Button */ - button = gtk_button_new_with_mnemonic ("_Blink"); - gtk_box_pack_start (GTK_BOX (vbox), button, TRUE, TRUE, 0); - g_signal_connect (button, "clicked", - G_CALLBACK (blink), - window); - - /* Menubar */ - gtk_box_pack_start (GTK_BOX (vbox), create_menubar (GTK_WINDOW (window)), - TRUE, TRUE, 0); - - /* Combo Box */ - gtk_box_pack_start (GTK_BOX (vbox), create_combo_box (), TRUE, TRUE, 0); - - add_buttons (NULL, vbox); - - return frame; -} - -guint32 -create_child_plug (guint32 xid, - gboolean local) -{ - GtkWidget *window; - GtkWidget *content; - - window = gtk_plug_new (xid); - - g_signal_connect (window, "destroy", - local ? G_CALLBACK (local_destroy) - : G_CALLBACK (remote_destroy), - NULL); - gtk_container_set_border_width (GTK_CONTAINER (window), 0); - - content = create_content (GTK_WINDOW (window), local); - - gtk_container_add (GTK_CONTAINER (window), content); - - gtk_widget_show_all (window); - - if (gtk_widget_get_realized (window)) -#if defined (GDK_WINDOWING_X11) - return GDK_WINDOW_XID (gtk_widget_get_window (window)); -#elif defined (GDK_WINDOWING_WIN32) - return (guint32) GDK_WINDOW_HWND (gtk_widget_get_window (window)); -#elif defined (GDK_WINDOWING_BROADWAY) - return (guint32) 0; /* Child windows not supported */ -#endif - else - return 0; -} diff --git a/testsuite/gtk/notify.c b/testsuite/gtk/notify.c index 4d297d425f..8f45289b8b 100644 --- a/testsuite/gtk/notify.c +++ b/testsuite/gtk/notify.c @@ -19,9 +19,6 @@ #include #include #include -#ifdef GDK_WINDOWING_X11 -#include -#endif #ifdef GDK_WINDOWING_WAYLAND #include "gdk/wayland/gdkwayland.h" #endif @@ -416,14 +413,6 @@ test_type (gconstpointer data) if (g_type_is_a (type, GTK_TYPE_MOUNT_OPERATION)) return; - /* Backend-specific */ -#ifdef GDK_WINDOWING_X11 - if (GDK_IS_X11_DISPLAY (gdk_display_get_default ())) ; - else if (g_type_is_a (type, GTK_TYPE_PLUG) || - g_type_is_a (type, GTK_TYPE_SOCKET)) - return; -#endif - klass = g_type_class_ref (type); if (g_type_is_a (type, GTK_TYPE_SETTINGS)) -- 2.30.2